Preparing the Core Data models for CloudKit

You might have noticed the following line in the code for creating a new CKRecord that was shown in the previous section:

let recordId = CKRecord.ID(recordName: UUID().uuidString, zoneID: defaultZoneId)

The recordName that is set on CKRecord.ID is the unique identifier that CloudKit uses to store records. When you want to import data from CloudKit, you can use recordName to check whether you have already saved a record in your local database. In addition to this unique identifier, CloudKit itself stores metadata about records. You saw this metadata when you added a new record type in the CloudKit dashboard and all these new properties that you didn't add yourself showed up.

Apart from the unique ...

Get Mastering iOS 12 Programming - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.