This is perhaps the most obvious use for CloudKit: syncing your users' data across their devices. Example: a note taking app where the user can create and read notes on any device associated with their iCloud account. Alternatives: Realm Mobile Platform, Firebase, iCloud KVS, iCloud Documents, custom web app.
Core Data provides powerful object graph management features for developing an app with structured data. CloudKit lets users access their data across every device on their iCloud account, while serving as an always-available backup service.
CloudKit is a framework that lets app developers store key-value data, structured data, and assets in iCloud. Access to CloudKit is controlled using app entitlements. CloudKit supports both public and private databases.
It's like this:
If you wanted to use CloudKit with Core Data, you'd have to write your own custom code to translate between managed objects and CloudKit records. It's not impossible, but it's more code to write. It might be more reliable but it's too soon to say for sure.
I wrote a blog post describing CloudKit from the perspective of someone who's used Core Data and iCloud in the past.
Update, June 2016: As of the most recent documentation for NSPersistentStoreCoordinator
, everything related to Core Data with iCloud is marked as deprecated. As a result it should probably be avoided for new development.
With iOS 13, Apple announced new features in Core Data to better work with CloudKit. The main addition is NSPersistentCloudKitContainer which basically manages syncing between Core Data and CloudKit for you.
You can learn more in the WWDC session Using Core Data with CloudKit.
Apple also released a nice collection of docs for this very usage: Mirroring a Core Data store with CloudKit.
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