title: iOS 13, CloudKit and CoreData Sync with custom zones for sharing
body: <p>During WWDC 2019 Apple introduced <code>NSPersistentCloudKitContainer</code> 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. </p>
  
  <p>Apple creates <code>com.apple.coredata.cloudkit.zone</code> 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 <code>NSPersistentCloudKitContainer</code> provides no possible way to change the zone for each entity in the CoreData. </p>
  
  <p>I was very happy to have found these</p>
  
  <pre class="lang-c prettyprint-override"><code>open func record(for managedObjectID: NSManagedObjectID) -&gt; CKRecord?
  
  open func records(for managedObjectIDs: [NSManagedObjectID]) -&gt; [NSManagedObjectID : CKRecord]
  
  open func recordID(for managedObjectID: NSManagedObjectID) -&gt; CKRecordID?
  
  open func recordIDs(for managedObjectIDs: [NSManagedObjectID]) -&gt; [NSManagedObjectID : CKRecordID]
  </code></pre>
  
  <p>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. </p>
  
  <p>My question in short is: how to take controll of how <code>NSPersistentCloudKitContainer</code> manages which record belongs to which zone other than <code>com.apple.coredata.cloudkit.zone</code></p>