Skip to content

Instantly share code, notes, and snippets.

@bismark
Last active January 1, 2016 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bismark/8064335 to your computer and use it in GitHub Desktop.
Save bismark/8064335 to your computer and use it in GitHub Desktop.
core data crash occurs on line 26: 2013-12-20 17:38:48.435 CoreDataCrash[23059:70b] *** Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for '0xcf61c00 <x-coredata://E61319FE-C903-4281-A90D-A0C46FE7F816/Widget/p7>''
self.parentMoc = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
self.parentMoc.persistentStoreCoordinator = self.persistentStoreCoordinator;
self.childMoc = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
self.childMoc.parentContext = self.parentMoc;
[self.parentMoc performBlock:^{
NSEntityDescription *desc = [NSEntityDescription entityForName:@"Widget" inManagedObjectContext:self.parentMoc];
Widget *w =[[Widget alloc] initWithEntity:desc insertIntoManagedObjectContext:self.parentMoc];
w.name = @"derp";
[self.parentMoc save:nil];
NSManagedObjectID *objectId = w.objectID;
[self.childMoc performBlock:^{
NSError *childExistingObjectError;
Widget *myW = (Widget *)[self.childMoc existingObjectWithID:objectId error:&childExistingObjectError];
myW.name = @"herp";
[self.parentMoc performBlock:^{
[self.parentMoc deleteObject:w];
[self.parentMoc save:nil];
[self.childMoc performBlock:^{
NSError *childSaveError;
@try {
[self.childMoc save:&childSaveError]; // CRASHES
} @catch (NSException *exception) {
NSLog(@"%@", exception); // NEVER CALLED
} @finally {
NSLog(@"finally?"); // NEVER CALLED
}
}];
}];
}];
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment