-
-
Save lemonkey/684f47ea429d0581c283d587fe850ad8 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