删除托管对象时,Core Data崩溃

时间:2011-10-29 13:32:19

标签: core-data ios5

CoreData: error: Serious application error.  
Exception was caught during Core Data change processing.  
This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification.  
-[__NSCFSet removeObject:]: attempt to remove nil with userInfo (null)
        *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFSet removeObject:]: attempt to remove nil'

应用程序在保存上下文操作时崩溃。 (案例是:我在tableView中执行segue,输入但甚至没有在destinationViewController中修改任何内容,当我在tableView应用程序中删除行时崩溃。

NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
        [context deleteObject:[self.fetchedResultsController objectAtIndexPath:indexPath]];
        // Save the context.
        NSError *error = nil;
        if (![context save:&error]) {
            NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
            NSLog(@"Unresolved error2 %@", [error localizedDescription]);
            abort();
        }

1 个答案:

答案 0 :(得分:1)

迪马,

您可能正在尝试删除具有必需参数的类。仔细检查您的型号或代码,以满足您的实体要求。如果我的假设是正确的,你只需要使关系成为可选的。

安德鲁