改变核心数据中托管对象模型属性值时的崩溃

时间:2011-03-09 13:48:22

标签: ios core-data uitableview nsfetchedresultscontroller nsfetchrequest

我有一个表视图控制器,它使用每行的获取结果控制器来获取项目。当选择一行时,它会推动一个新的视图控制器来编辑该特定的托管对象模型 - 当我编辑并尝试保存时,我得到以下内容。原因是什么? 感谢

Serious application error.  Exception was caught during Core Data change processing.  This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification.  Can't use in/contains operator with collection 0 (not a collection) with userInfo (null)
Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
_Unwind_Resume called from function -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] in image CoreData

1 个答案:

答案 0 :(得分:3)

这部分错误:

...Can't use in/contains operator with collection 0 (not a collection)...

通常表示错误的谓词,很可能是在获取或获取的属性上。您很可能尝试在谓词中使用INCONTAINS运算符,而不提供目标对象属性可能包含的实际值集合。例如,

NSPredicate *p=[NSPredicate predicateWithFormat:@"attribute1 IN %@", @"a string not an array"];

... VS:

NSArray *inCollection=[NSArray arrayWithObjects:@"Tom",@"Dick",@"Harry",nil];
NSPredicate *p=[NSPredicate predicateWithFormat:@"attribute1 IN %@", inCollection];

据推测,你在编辑中改变的东西是在表格的提取中破坏你的谓词。您还需要确保已实现获取的结果控制器的委托方法,以便在插入,删除或更改对象时,将正确更新表以反映这些更改。

(其余的错误是无关紧要的。这只是一个警告你无法做任何事情的框架。)