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

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: com.apple.main-thread 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.

Replay

Category: ios Time: 2016-07-31 Views: 6

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.188 (s). 12 q(s)