title: CoreData + CloudKit reverting a CKShare to CoreData store
body: <p>I use NSPersistentCloudKitContainer to save objects in CoreData + CloudKit. I have integrated a sharing function that moves an object to a separate zone to share using UICloudSharingController, as described in <a href="https://developer.apple.com/wwdc21/10015" rel="nofollow noreferrer">https://developer.apple.com/wwdc21/10015</a></p>
  <p>When the user stops sharing, I want the object in the shared zone to be deleted, and moved back to the CoreData + CloudKit standard private zone. Deleting the CKShare and its zone is done using the following method:</p>
  <pre><code>/**
   Delete the Core Data objects and the records in the CloudKit record zone associcated with the share.
   */
  func purgeObjectsAndRecords(with share: CKShare, in persistentStore: NSPersistentStore? = nil) {
      guard let store = (persistentStore ?? share.persistentStore) else {
          print(&quot;\(#function): Failed to find the persistent store for share. \(share))&quot;)
          return
      }
    
      persistentContainer.purgeObjectsAndRecordsInZone(with: share.recordID.zoneID, in: store) { (zoneID, error) in
          if let error = error {
              print(&quot;\(#function): Failed to purge objects and records: \(error)&quot;)
          }
      }
  }
  </code></pre>
  <p>How do I deep copy the CKShare back to the private zone before deleting it?</p>