I followed the same steps as in "Using Core Data With CloudKit":
What am I missing?
NSPersistentCloudKitContainer seems too automatic/opaque. (I say this before the session has taken place, though.) It’s a whole new managed approach where Core Data owns the CloudKit container and handles it.
So CloudKit Core Data Sync doesn’t merge in remote changes before syncing up the modified local record, and sends whole record not just changed fields, causing it to overwrite whatever changes another device made that was not yet received, seems like a dealbreaker. Update (2019-06-04): Malcolm Hall:
sadly Core Data CloudKit isn’t using CKReference for related records, just using a string field, thus losing integrity. I was really hoping they would make the public the CKReferenceActionValidate that Notes uses for e.g. the one-to-many folder notes relation. Update (2019-06-06): Tom Harrington:
To see the changes with Simulators you have to quit the app, and reload it (or build & run).
Simulators have never been able to receive Remote Notifications to trigger an iCloud sync so you need to manually force a sync, but I've found that syncing cannot be triggered manually from the menu in my Xcode 11 beta (gives an error).
There is a good post by Andrew Bancroft about some other things such as setting the automaticallyMergesChangesFromParent property to true, but this doesn't make a difference when using Simulators (EDIT: It does, but I didn't realise as I was just building & running each time).
Andrew's Post: https://www.andrewcbancroft.com/blog/ios-development/data-persistence/getting-started-with-nspersistentcloudkitcontainer/#where-s-my-data
I'm in the same boat as I can't afford to install any beta software (except Xcode) so I'm going to have to stick with the simulators. But my experience of converting an existing App to CloudKit has been very, very positive. I just had to do three things to my existing project:
...and that's it! Mind blown.
All my nested many-to-many relationships appear to work perfectly.
I still need to work out how to sync images currently stored as JPGs in the users Documents directory but I suspect they'll need to be stored in Core Data as BLOBs to enable conversion to CKAssets in the background.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With