我试图保存时,核心数据无法解决问题

时间:2014-06-06 10:10:42

标签: objective-c core-data xcode5

  

因未捕获的异常'NSObjectInaccessibleException'而终止应用程序,原因:'CoreData无法解决

错误

起初我认为这是因为我要更新的对象有错误的NSManagedObjectContext

所以在此之前我做了:

    for (NSManagedObject * mo in moc.updatedObjects.allObjects) {
        [mo assertNSManagedObjectisHealthy];
    }

-(void) assertNSManagedObjectisHealthy
{
    //AssertMainThread;
    NSManagedObjectContext * moc = [BGMDCRManagedObjectContextThreadHandler managedObjectContext];
    NSManagedObjectContext *mocObject=self.managedObjectContext;
    NSAssert (moc==mocObject,@"Something is wrong why moc is not the same");
}

然后错误实际发生在这里:

[moc performBlockAndWait:^{
    @synchronized([BGFetchClass class])
    {
        saveSuccesfully = [moc save:&error]; //Error here
        if (!saveSuccesfully) {
            CLog(@"Error in Saving %@", error);
        }
        else{
        }
    }
}];

0 个答案:

没有答案