Created
October 4, 2013 15:02
-
-
Save cgreening/6827449 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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