Managing Persistent Store Changes
The sequence of events when a persistent store changes has been simplified. There are now five basic steps involved:
1. You receive NSPersistentStoreCoordinatorsStoresWillChange-Notification
.
2. Save and reset your managed object context. If you use the names shown in Listing 17.1, your code would be similar to the following:[_managedObjectContext save:];[_managedObjectContext reset];
The argument after save
is a pointer to an NSError
.
3. Core Data removes the store.
4. You receive NSPersistentStoreCoordinatorsStoresDidChange-Notification
.
5. Save the managed object context with the new store:
[_managedObjectContext save:];
If you are used to WWDC 2012, you may be thinking about dropping a persistent store and ...
Get Learning iCloud Data Management: A Hands-On Guide to Structuring Data for iOS and OS X 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.