Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSPersistentStoreCoordinator *coordinator = [appDelegate persistentStoreCoordinator];
- NSManagedObjectContext *newContext = [[NSManagedObjectContext alloc] init];
- [newContext setPersistentStoreCoordinator:coordinator];
- [[NSNotificationCenter defaultCenter] addObserver:appDelegate selector:@selector(contextDidSaveFromSeparateThread:) name:NSManagedObjectContextDidSaveNotification object:newContext];
- // model work done here
- // when this executes the notification fires which should execute contextDidSaveFromSeparateThread: which then merges the contexts
- if (![newContext save:&saveError]) {
- NSLog(@"ERROR saving in registerTheUser: %@", saveError);
- }
- [[NSNotificationCenter defaultCenter] removeObserver:appDelegate name:NSManagedObjectContextDidSaveNotification object:newContext];
- [newContext release], newContext = nil;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement