问题
I have been trying very unsuccessfully to create a simple UIManagedDocument
library style application (separate documents saved to iCloud).
I am confused with the following:
Do I subclass UIManagedDocument
and set up the persistentStoreCoordinator
, ManagedObjectModel
& ManagedObjectContext
within this subclass, or are these supposed to be configured within the AppDelegate
(and if so, how do I go about refreshing the persistentStoreCoordinator
to look at the new file - it seems that once that has read a persistentStore
that I can't get it to read a new persistent store)?
回答1:
Richard's example is an excellent example. I used it and the PragmaProg book on core data http://pragprog.com/book/mzcd2/core-data as a guide for creating my managed document module on github. See: https://github.com/dtrotzjr/APManagedDocument
My code makes use of iOS 7 iCloud Core Data behavior which I cannot comment on publicly until the NDA is lifted. Feel free to ping me directly if you have any questions.
回答2:
I've just posted a project based on Rick Warren's example: MultiDocumentPlusUUID. In his "Syncing Multiple Core Data Documents Using iCloud" post, Rick writes:
Another bug often shows up when I start trying to pass changes back and forth between devices that both have the same file open. The first sync always seems to work--and it seems to work pretty well as long as each subsequent sync is in the same direction.
MultiDocumentPlusUUID compiles and runs on iOS 7.1b4, and can ping-pong updates to a given document successfully.
来源:https://stackoverflow.com/questions/8705964/uimanageddocument-example-tutorial