创建 NSFetchedResultsController 对象时出现以下错误
编辑
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
// Edit the entity name as appropriate.
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Subscriptions" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
// Set the batch size to a suitable number.
[fetchRequest setFetchBatchSize:20];
编辑结束
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:nil];
#0 0x977109c6 in __pthread_kill ()
#1 0x96296f78 in pthread_kill ()
#2 0x96287bdd in abort ()
#3 0x0022eb71 in uncaught_exception_handler ()
#4 0x024b70fc in __handleUncaughtException ()
#5 0x0264af0f in _objc_terminate ()
#6 0x052fb8de in safe_handler_caller ()
#7 0x052fb946 in std::terminate ()
#8 0x052fcab2 in __cxa_throw ()
#9 0x0264ade1 in objc_exception_throw ()
#10 0x00617f39 in -[NSFetchedResultsController initWithFetchRequest:managedObjectContext:sectionNameKeyPath:cacheName:] ()
我应该开始寻找问题的任何想法。这个错误没有任何帮助。
我已经放了一个断点并且已经检查了输入 init 函数有两个输入,一个是托管对象,第二个是获取请求。
与下面的答案中提到的不同,这两个对象都是有效的。
** 解决方案 ** 看来排序描述符是强制性的,多亏了 Rog