因未捕获的异常'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{
}
}
}];