Core data 保存managedObjectContext时崩溃,使用';NSInvalidArgumentException';,但只是偶尔

Core data 保存managedObjectContext时崩溃,使用';NSInvalidArgumentException';,但只是偶尔,core-data,nsmanagedobjectcontext,Core Data,Nsmanagedobjectcontext,我不断从managedObjectContext上的save:命令中获得崩溃。它甚至没有实现NSLog语句,所以我看不到未解决的错误语句,所以我无法找出问题所在。它不是每次都发生,只是偶尔发生 下面是代码(基本上希望增加一个计数器): 或者这个: 2010-08-20 08:12:20.594 AppName[23501:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reaso

我不断从managedObjectContext上的save:命令中获得崩溃。它甚至没有实现NSLog语句,所以我看不到未解决的错误语句,所以我无法找出问题所在。它不是每次都发生,只是偶尔发生

下面是代码(基本上希望增加一个计数器):

或者这个:

  2010-08-20 08:12:20.594 AppName[23501:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFSet controllerWillChangeContent:]: unrecognized selector sent to instance 0xe54f560'
甚至这个:

  2010-08-19 23:09:59.337 AppName[761:307] Serious application error.  Exception was caught during Core Data change processing.  This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification.  -[UITableViewLabel controllerWillChangeContent:]: unrecognized selector sent to instance 0x7f0a860 with userInfo (null)
  2010-08-19 23:09:59.356 AppName[761:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewLabel controllerWillChangeContent:]: unrecognized selector sent to instance 0x7f0a860'
然后,它在第一次抛出时显示调用堆栈,然后是一个通知(在抛出“NSException”实例后终止调用),“[切换到进程23501]”和“程序接收信号:“SIGABRT”。”

我认为这个问题与CoreData有关,但我不确定。我清理了构建和目标,但似乎没有帮助。我尝试锁定/解锁ManagedObjectContext,但没有帮助


如果您有任何关于从何处开始寻找解决方案的想法,我们将不胜感激。

看起来您正在释放一个
UIViewController
,而没有释放其关联的
NSFetchedResultsController
NSFetchedResultsController
正在尝试通知其代表(很可能是退出时保存的
UIViewController
)。

要详细说明Marcus的答案,您需要确保在视图消失时为NSFetchedResultsController清除委托:

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    self.fetchedResultsController.delegate = nil;
}

是的,问题肯定是,获取的结果控制器正在向不理解该消息的对象发送一条用于UITableView(或其数据源或委托)的消息。它实际上与核心数据没有任何直接关系。非常感谢你们两位……如果我理解正确的话,有些事情(如UIViewController、datasource或delegate)在不应该的时候被释放,所以我应该尝试查找不应该在那里的autorelease或release语句,或者插入一个“retain”语句来保持某个对象足够长的时间(NSFetchedResultsController实际上从未达到保存的目的)
  2010-08-19 23:09:59.337 AppName[761:307] Serious application error.  Exception was caught during Core Data change processing.  This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification.  -[UITableViewLabel controllerWillChangeContent:]: unrecognized selector sent to instance 0x7f0a860 with userInfo (null)
  2010-08-19 23:09:59.356 AppName[761:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewLabel controllerWillChangeContent:]: unrecognized selector sent to instance 0x7f0a860'
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    self.fetchedResultsController.delegate = nil;
}