Skip to content

Instantly share code, notes, and snippets.

@quellish
Created September 29, 2014 07:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save quellish/3500621b16a276e5fde8 to your computer and use it in GitHub Desktop.
Save quellish/3500621b16a276e5fde8 to your computer and use it in GitHub Desktop.
Recursive save of managed object context
- (void) saveManagedObjectContext:(NSManagedObjectContext *)managedObjectContext withCompletion::(void (^)(BOOL, NSError *))completio{
managedObjectContext performBlock:^{
NSError *error = nil;
if (![managedObjectContext save:&error]){
completion(NO, error);
} else {
if ([managedObjectContext parentContext] != nil){
[self saveManagedObjectContext:[managedObjectContext parentContext] withCompletion:completion];
} else {
completion(YES, error);
}
}
}];
}
@SandeepAggarwal
Copy link

This is creating a deadlock in my code.Can you please tell how?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment