title: CloudKit CKRecord Deletion - How to Obtain RecordIDs
body: <p>For the app I'm working on, a user can create an account and can create posts for other users to see.</p>
  <p>I want to provide the option for users to delete their account &amp; posts but see that the record deletion function requires the object's recordID (<a href="https://developer.apple.com/documentation/cloudkit/ckdatabase/1449122-delete" rel="nofollow noreferrer">https://developer.apple.com/documentation/cloudkit/ckdatabase/1449122-delete</a>).</p>
  <p>Is there a way I can retrieve and save the CloudKit generated recordID metadata for records, so the recordIDs can be utilized for record deletion later?</p>
  <p>I've tried things like the following to no avail:</p>
  <pre><code>let rN = record.object(forKey: &quot;recordName&quot;) as? String ?? nil
              
  if let recordName = rN
  {
       personP.recordID = CKRecord.ID.init(recordName: recordName)
  }
  </code></pre>
  <p>For some more context, I've been using a separate String field as an identifier for users to fetch their existing account/posts when they log into the app.</p>
  <p>Alternatively: is there a way to delete records without needing the CKrecordID (for example, being able to delete all records returned from a CKQueryOperation)?</p>
  <p>Any guidance or suggestions would be greatly appreciated.</p>