The easiest way to access a readily available save method is by importing AppDelegate into the class that wants to execute the save. Then we call a method in AppDelegate:
1 2 |
AppDelegate *myAppDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate]; [myAppDelegate saveContext]; |
No reference to fetchedResultsController or managedObjectContext or any complex &error statements.
If you have direct access to the managed object context you can also call something like this:
Or, if you’re interested in a potential error that may occur during saving: