I'm adding iCloud syncing to my app. My UIManagedDocument
store is in the sandbox, and its change log is in iCloud (specified by NSPersistentStoreUbiquitousContentURLKey
). The problem is that when I install and run the app for the 1st time on a 2nd device, it takes many minutes to do the initial sync (to pull the updates created by the 1st device). This is a real issue because that sync is evidently happening inside UIManagedDocument:saveToURL:completionHandler
. So the completion handler block takes a long time to get called, and if I access my UIManagedDocument
before UIManagedDocument:saveToURL
returns, I understandably get a crash.
I want to open the database quickly and then do the sync in the background. How can I do it?