I've managed to get my existing core data app to work with iCloud. After days of study, it was actually surprisingly simple. It seems that 3 things are essential:
to add an entitlements file (in recent Xcode, this can be done using by selecting the target, select "Summary pane", scroll down, check enable entitlements"
to add the correct options while adding the persisten store, in my case
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: // other options @"<arbitrary name>", NSPersistentStoreUbiquitousContentNameKey, iCloudURL, NSPersistentStoreUbiquitousContentURLKey, nil]
where
NSURL * iCloudURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
The `nil' here indicating that information from the Entitlements.plist file is used.
- enabling iCloud support for the app through the developer portal. This might involve generating a unique app-ID, something I hadn't done before.
Actually, at the moment I am not sure this last step is crucial for development---i've enabled another app without this last step and it seems to work.
Anyhow, I've noticed that two existing core data bases of the same app on different iDevices will synchronise new entries to the core data stack, but will not automatically sync the existing records.
One way of syncing data from device A to B is to delete the existing core data database on B, and then restart the app on B. However, this is not a proper merge.
Does anybody know a way to merge two existing core data databases on different apps at the moment the apps are upgraded to use iCloud support, i.e., use the options above and all that?
Thanks