7

During WWDC 2019 Apple introduced NSPersistentCloudKitContainer which allows for syncing of CoreData with CloudKit. It is a great addition. In iOS 13 in notes app also user is allowed to to share the entire note "FOLDER" with another user. Given that Apple uses CloudKit for Notes app, I wanted to create something similar to understand how it better works.

Apple creates com.apple.coredata.cloudkit.zone zone and basically syncs all data there into that zone if all setup conditions are met. However there is no guideline when user would like to share data. According to a former WWDC talk, sharing would be possible mainly via creating a CUSTOM ZONE. However the new NSPersistentCloudKitContainer provides no possible way to change the zone for each entity in the CoreData.

I was very happy to have found these

open func record(for managedObjectID: NSManagedObjectID) -> CKRecord?

open func records(for managedObjectIDs: [NSManagedObjectID]) -> [NSManagedObjectID : CKRecord]

open func recordID(for managedObjectID: NSManagedObjectID) -> CKRecordID?

open func recordIDs(for managedObjectIDs: [NSManagedObjectID]) -> [NSManagedObjectID : CKRecordID]

as they gave this impression that the container calls this methods to retrieve the CKRecord and hence a point to modify informations such as zone etc. but after the setup I realized when I add a new entity to my CoreData, these functions even though when overrides are not called.

My question in short is: how to take controll of how NSPersistentCloudKitContainer manages which record belongs to which zone other than com.apple.coredata.cloudkit.zone

Congruent Tech. UG
  • 1,408
  • 2
  • 12
  • 21

0 Answers0