Skip to content

Instantly share code, notes, and snippets.

@drinkius
Created March 28, 2017 13:41
Show Gist options
  • Save drinkius/0b66842b3fb05cbab95c121b7361d9ea to your computer and use it in GitHub Desktop.
Save drinkius/0b66842b3fb05cbab95c121b7361d9ea to your computer and use it in GitHub Desktop.
Save managed object context
NSManagedObjectContext *context = object.managedObjectContext;
while (context != nil) {
NSError *error = nil;
BOOL result = [context save:&error];
NSAssert(result != NO, @"[ERROR]: Context was not saved");
if (result) {
context = context.parentContext;
} else {
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment