Ios 使用'时崩溃;filteredSetUsingPredicate';在CoreData NSSet上(NSInvalidArgumentException:set参数不是NSSet)

Ios 使用'时崩溃;filteredSetUsingPredicate';在CoreData NSSet上(NSInvalidArgumentException:set参数不是NSSet),ios,objective-c,core-data,nspredicate,nsset,Ios,Objective C,Core Data,Nspredicate,Nsset,假设我有一个NSManagedObject动物园,他有一个和“猫”命名的猫的连接,这个连接是NSSet。 当我使用函数“”时,出现以下代码的崩溃: Zoo *zoo = //intance of our zoo with all the animals - from core data NSPredicate *predicate = [NSPredicate predicateWithFormat:@"catSize == Big"]; NSArray *arrayOfCats = [zoo

假设我有一个NSManagedObject动物园,他有一个和“猫”命名的猫的连接,这个连接是NSSet。 当我使用函数“”时,出现以下代码的崩溃:

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];
崩溃堆栈如下所示:

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
这种情况偶尔会发生一次,可能与我在后台环境中所做的更新和删除有关(如果我坚持这个示例,则添加或删除猫)。
知道如何保护我的应用程序不被崩溃吗?对属性cats的任何访问都会导致崩溃。

您应该查看关系删除规则,确保其设置正确

可能重复的