Search code examples
ioscloudkit

Generate CKRecord classes with properties like CoreData


I'm migrating an app from CoreData to CloudKit. I hate using string-based key-value coding, because it prevents autocomplete and makes refactoring harder. With CoreData, we can have classes with properties automatically generated so that changes in the data model are automatically reflected in the generated classes and their properties. Is a similar process available for CloudKit?


Solution

  • The new NSPersistentCloudKitContainer in iOS 13 bridges CoreData and CloudKit. This means local storage remains in CoreData and can use CoreData auto-generated classes and properties for accessing values. NSPersistentCloudKitContainer handles the interface with CloudKit so no KVC is required.