I have a question regarding icloud store with core data store in iOS7. In the apple WWDC conference, it was mentioned that the core data store can be created in the sandbox and when the app starts receiving responses from icloud, the changes in the core data store will be merged into icloud store.
Now, (I might be wrong), but the conference further mentioned that the local core data store would be deleted once the app has switched over to the icloud store. So, my question is can a local core data store co-exist with the icloud store in iOS7 (so that the user has capability to work offline with data) ? And is there any sample code for this ?
In iOS 7, the Core Data framework takes care of managing the local store until the iCloud store is setup and available. This pattern also works for when the app is offline and it doesn't delete any data when the app goes offline (just double checked on my app in development).
The iCloud store will be deleted in another case. That's in the event the iCloud user account changes in which case the respective iCloud store file will be removed. In such case, there is a new API NSPersistentStoreCoordinatorStoresWillChangeNotification
that allows you to store unsaved data before the store becomes unavailable. If the user logs in later with that same account, the data will be restored from iCloud (check the WWDC 2013 session 207 video at 15' for more on this).
As for sample code, there isn't any as of today. There is, though, iCloud sample code shared by AppleSpaceMan on the developer forum, which is what I used as a base and worked nicely.