Skip to content

Instantly share code, notes, and snippets.

@alattis
Created April 3, 2013 02:22
Show Gist options
  • Save alattis/5297950 to your computer and use it in GitHub Desktop.
Save alattis/5297950 to your computer and use it in GitHub Desktop.
thread safe core data the easy way
//in background operation
backgroundMOC = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
[backgroundMOC setParentContext:appDelegate.managedObjectContext];
//in app delegate
if (coordinator != nil) {
_managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
[_managedObjectContext setPersistentStoreCoordinator:coordinator];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment