I am working on a lightweight wrapper for UIManagedDocument which manages the existence of multiple documents in a person's iCloud account. See: APManagedDocument
I am relying heavily on the use of fallback stores in iOS 7 and caring as little as possible about the current state of iCloud. Thus letting core data do what it does best in regards the fallback stores based on my understanding from the WWDC 2013 Video - Session 207 What’s New in Core Data and iCloud
First a quick overview of how my manager works:
I create all my UIManagedDocuments
in the local sandbox and set the appropriate persistent store options to enable iCloud sync. I never move the UIManagedDocument
package from the sandbox.
Using local storage: 0
message.)So far everything is working great but I ran into a little pickle with the scenario where the user creates a new document prior to logging into iCloud and I am presented with the following issues:
My big question is what is the proper approach when it comes to the local fallback store? Where are my assumptions wrong?
This is one of the final pieces I need to ship my iOS 7 update. Any and all feedback would be greatly appreciated, and will be reflected in my github project so others can learn from my mistakes.
I have a duplicate of this question in the Apple Developer Forums. I will update this thread with any findings I get from there. I think this question is important and remains unresolved with the release of iOS 7. Fallback stores are a huge advancement in iCloud technology but the local storage part is still a little undefined.
I have worked around this for now since I cannot seem to get information as to how fallback stores are supposed to work in this scenario.
Basically what I do now is if the user is not logged in I create the document w/o iCloud sync options enabled.
Then at startup if iCloud is enabled I perform a scan for documents that need to be migrated and migrate them simply by opening them with the iCloud options enabled. Once opened I close the document as that is enough to get them migrated and scannable via a meta data scan.
Finally after the migration is done I kick off a new scan for documents.
It works but it is a bit of a hack.
Refer to the APManagedDocument commit: 421aaae