Skip to content

Instantly share code, notes, and snippets.

@donnywals
Created June 4, 2019 17:32
Show Gist options
  • Save donnywals/8e61c1857cc5c33c6667ee98795af19e to your computer and use it in GitHub Desktop.
Save donnywals/8e61c1857cc5c33c6667ee98795af19e to your computer and use it in GitHub Desktop.

CloudKit and Core Data

  • Core Data and CloudKit are conceptually similar but implemented in very different ways.
  • You can now check a use CloudKit checkbox when you add Core Data to your app.
  • You need to add the iCloud and Background mode capabilities yourself in order to use CloudKit and update your app in the background.
  • Xcode creates a container identifier for your app.
  • NSPersistentCloudKitContainer managed persistent stores that sync data too iCloud. The CloudKit container is a subclass of the NSPersistentContainer.
  • The CloudKit container contains all the boilerplate code that you would normally have to write yourself.
  • Apple asks for feedback on this container explicitly.
  • CloudKit container creates a local replica of the CloudKit store.
  • You can add separate stores for cloud and non-cloud synced entities. You can use persistent store descriptions to tell the container which stores it manages.
  • A persistent CloudKit container can share data across multiple applications by creating a shared sqlite file.
  • The container understands how to optimize certain CloudKit storage aspects, for instance, it's able to use either an asset or plain string to store text of variable length.
  • One to many relationships do not use ckreference because there is a limit of 750 references for an item. Instead they use UUIDs so they have unlimited references.
  • Many to many relationships are implemented through a linking table.
  • When modeling for collaboration and you have a textfield, you might want to use a to many relationship for the textfield content so conflicts can't happen (as easily).

Worth watching, documentation is updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment