Question

I've been using a UIManagedDocument inside of a Singleton class. I create, open and perform with etc and everything was going fine until I needed to have two separate Data stores with an identical Schema. I've made sure everything was done in the same way through the same class (simply storing the second Database in a second static variable and using a BOOL to ensure the correct document gets used.

The problem is that while my original document works fine and the second document gets created fine, I can never seem to get the second document to open when I call 'openWithCompletionHandler' and pass in the block I need it to perform.

So my question is: Are there any special considerations I need to take into account when using multiple UIManagedDocuments in the one project?

Thanks in advance.

Was it helpful?

Solution

Yes there are. The big one is to make sure they both have unique NSPersistentStoreUbiquitousContentNameKey values set in the document's persistentStoreOptions.

See Rich Warren's well documented example: Syncing Multiple Core Data Documents Using iCloud

And also my GitHub repo that makes multiple documents easier to set up and maintain in some cases: APManagedDocument

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top