Created
September 29, 2014 07:45
-
-
Save quellish/3500621b16a276e5fde8 to your computer and use it in GitHub Desktop.
Recursive save of managed object context
This file contains hidden or 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
- (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); | |
} | |
} | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is creating a deadlock in my code.Can you please tell how?