Saving and Rolling Back Your Changes

If the user taps the Save button, he has indicated his intention to keep the changes made to the editMovie. In the saveButtonTouched: method, the fields not updated with delegate methods are saved to the editMovie property:

NSString *movieTitle = [self.movieTitle text];[self.editMovie setTitle:movieTitle];NSString *movieDesc = [self.movieDescription text];[self.editMovie setMovieDescription:movieDesc];BOOL sharedBool = [self.sharedSwitch isOn];NSNumber *shared = [NSNumber numberWithBool:sharedBool];[self.editMovie setLent:shared];

Then the managed object context is saved, making the changes permanent.

NSError *saveError = nil;[kAppDelegate.managedObjectContext ...

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.