// Save changes if any.
NSError *error;
if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
// TODO: handle this error better.
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
// Save changes if any. NSError *error; if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
Share
That depends. If you’re sure that changes have been made to the
managedObjectContext, then there’s no need to check. However, if there’s any possibility that changes have not been made, then you should check before saving.Check out the application delegate of the CoreDataBooks Xcode sample app for examples of both these scenarios.