Crashing when using 'filteredSetUsingPredicate' on CoreData NSSet (NSInvalidArgumentException: set argument is not an NSSet)

July 31   ios 0 5 Views

Let's say I have NSManagedObject Zoo, and he got connection oneToMany to 'Cat' named cats, this connection is NSSet. When I use the function 'filteredSetUsingPredicate', I get a crash with the following code:

Zoo *zoo = //intance of our zoo with all the animals - from core data  NSPredicate *predicate = [NSPredicate predicateWithFormat:@"catSize == Big"]; NSArray *arrayOfCats = [zoo.cats filteredSetUsingPredicate:predicate]; 

The crash stack is as follow:

Terminating app due to an uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSMutableSet unionSet:]: set argument is not an NSSet'  Crashed: 1  CoreFoundation                 0x180f51798 -[NSMutableSet unionSet:] + 96 2  CoreData                       0x182f24154 -[_NSFaultingMutableSet willReadWithContents:] + 716 3  CoreData                       0x182f05f10 -[_NSFaultingMutableSet count] + 28 4  Foundation                     0x181a93828 -[NSSet(NSPredicateSupport) filteredSetUsingPredicate:] + 68 

This happens only once in a while, and probably has to do with updates and deletion that I do in the background context (adding or deleting cats if I stick to this example). Any idea how can I protect my application from crashing? Any access to the property cats cause a crash.



PC site About | Contact

©2016 all rights reserved

processed in 0.118 (s). 5 q(s)