Skip to content

Instantly share code, notes, and snippets.

@cgreening
Created October 4, 2013 15:02
Show Gist options
  • Save cgreening/6827449 to your computer and use it in GitHub Desktop.
Save cgreening/6827449 to your computer and use it in GitHub Desktop.
self.backgroundManagedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
[self.backgroundManagedObjectContext setPersistentStoreCoordinator:persistentStoreCoordinator];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backgroundContextDidSave:) name:NSManagedObjectContextDidSaveNotification object:self.backgroundManagedObjectContext];
- (void)backgroundContextDidSave:(NSNotification *)didSaveNotification {
[self.managedObjectContext performBlock:^{
NSDate *start = [NSDate date];
[self.managedObjectContext mergeChangesFromContextDidSaveNotification:didSaveNotification];
DLog(@"Merging background changes took %f", [[NSDate date] timeIntervalSinceDate:start]);
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment