Database Reference
In-Depth Information
Switching iCloud accounts
On occasion, a user may disable iCloud syncing from his account while your app is
running. Or, a user may decide to switch iCloud accounts on her device. What
should happen to your app's data when this occurs?
When a user logs out of an account, Core Data will manage the deletion of the
underlying fallback data store for you. Since the data always exists in the cloud, the
fallback store can be rebuilt using iCloud once the user logs back into her account.
Core Data sends two useful notifications when handling iCloud account changes:
NSPersistentStoreCoordinatorStoresWillChangeNotification
NSPersistentStoreCoordinatorStoresDidChangeNotification .
The “will change” notification signals that a persistent store coordinator is adding or
removing a persistent store. As such, the notification will contain instances of
NSPersistentStore objects being added and removed. Core Data sends this
notification only for coordinators with iCloud stores configured and running.
Core Data fires the “did change” notification after the persistent stores have been
swapped out and the coordinator is ready to supply the new data.
You're going to modify CloudNotes to respond to these notifications to handle
changes to iCloud accounts.
 
 
Search WWH ::




Custom Search