简体   繁体   中英

Crashing when Changing Attribute Value of Managed Object Model in Core Data

I have a table view controller which fetches items using fetched results controller for each row. When a row is selected it pushes a new view controller to edit that particular managed object model - when I edit and try to save I get the following. What is the cause? Thanks

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

.

This part of the error:

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

usually indicates a bad predicate, most likely on a fetch or fetched attribute. You've mostly likely tried to use the IN or CONTAINS operator in a predicate without supply an actual collection of values that the targeted objects attributes could be in. Eg

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];

Presumably, something you are changing in your edit is breaking your predicate in the table's fetch. You also want to make sure you've implemented the fetched results controller's delegate methods so that if an object is inserted, deleted or changed, the table will be properly updated to reflect those changes.

(The rest of the error is irrelevant. It's just a framework warning you can't do anything about.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM