“错误:此过程已调用NSArray获取方法...”当iCloud推送管理对象时 [英] "Error: this process has called an NSArray-taking method..." when iCloud pushes managed objects

查看:201
本文介绍了“错误:此过程已调用NSArray获取方法...”当iCloud推送管理对象时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于通过iCloud更新发送的每个托管对象,此警告/错误都会发送到控制台:

For every managed object that is sent via iCloud update, this warning/error is sent to the console:


***错误:这个过程调用了一个NSArray-taking方法,如
initWithArray :,并在一个NSSet对象中传递。

*** ERROR: this process has called an NSArray-taking method, such as initWithArray:, and passed in an NSSet object. This is being worked-around for now, but will soon cause you grief.

我的托管对象是客户端,并且有

My managed objects are Clients and have a one to many relationship with assessments as shown below.

    class Client: NSManagedObject {

        //other NSManaged vars are here

        @NSManaged var assessment: NSOrderedSet
}



根据这个错误的时间(在无处不在的更新期间)和事实,这是我唯一的使用NSSet对象在我的项目,我可以假设一个函数在此更新期间传递NSOrderedSet当它期望一个NSArray 。

Judging by the timing of this error (during ubiquitous updates) and the fact that this is my only use of NSSet objects in my project, I can presume that a function during this update is being passed an NSOrderedSet when its expecting an NSArray.

关闭iCloud会删除错误。

Turning off iCloud removes the errors.

我发现另外两个人有一个非常相似的问题:
使用启用了iCloud的Core Data NSArray获取方法

I found two other folks with a very similar issue: Using iCloud enabled Core Data NSArray-taking method

对象之间的核心数据关系< a>

Core Data Relation between Objects

但是,两者都不能解决我的问题。一切正常工作,现在,但它很快会导致你的悲伤。

However, neither offers any solution to my problem. Everything is working fine right now, however "it will soon cause you grief."

如果这里没有解决,我会把这个问题与苹果dev支持。

If this isn't resolved here, I'll take this issue up with the apple dev support.

推荐答案

我想出了如何解决这个错误经过大量的研究。 (没有从苹果开发论坛的帮助)。

I figured it out how to fix this error after much research. (No help in from the Apple Dev forums).

这是错误是由Swift 1.2升级造成的。他们鼓励您使用新的Set<>类,而不是NSSet。

This is error is caused by the Swift 1.2 upgrade. They encourage you to use their new Set<> class instead of NSSet. The error was a vague way of reinforcing that claim.

我的数据排序最终是由我的NSFetchedResultsController处理,所以我不需要存储的数据进行排序。所以我开始一个任务来改变我的一对多关系从NSOrderedSet到Set的数据类型。

Ordering of my data was ultimately handled by my NSFetchedResultsController, so I didn't need the stored data to be ordered. So I set out on a task to change the data type for my one to many relationship from NSOrderedSet to Set.

所以我创建了一个新的数据模型,选择我的关系和在数据模型检查器中取消选中有序。然后在下一次运行中迁移到新模型。 (如下所示)

So I created a new data model, selected my relationship and unchecked "Ordered" in the data model inspector. Then migrated to the new model in the next run. (as shown below)

一旦完成,我将我的托管对象子类中的数据类型从NSOrderedSet更改为Set。 (或Set)。这产生编译器错误,很容易修复在我的代码。

Once that was done, I changed the data type in my managed object subclass from NSOrderedSet to Set. (or Set). That generated compiler errors that were easy to fix throughout my code.

新的Set类容易转换为数组: Array(mySet)

The new Set class easily converts to an array: Array(mySet)

要将对象插入集合,有一个简单的插入方法。 foo.mySet.insert(objectToInsert)

To insert an object to the set, there's an easy insert method. foo.mySet.insert(objectToInsert).

旁注:将我的关系转换为Set也固定了一些奇怪订购问题我对我的表视图和NSFetchedResultsController。

Side note: Converting my relationship to a Set also fixed some weird ordering issues I was having with my table views and the NSFetchedResultsController.

然后我运行程序,生成数据,卸载程序。再次运行程序,并观看辉煌的iCloud数据填充,没有恼人的错误。

Then I ran the program, generated data, uninstalled the program. Ran the program again and watch the glorious iCloud data populate without the annoying errors.

Boom。我希望这可以节省一个人在那里10个小时的动荡(我尝试了很多不同的东西..)我花了解决这个问题。

Boom. I hope this saves someone out there the 10 hours of turmoil (I tried a lot of different things..) I spent to fix this.

这篇关于“错误:此过程已调用NSArray获取方法...”当iCloud推送管理对象时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆