How to initialize CKRecord with both zoneID and recordID?

You can specify both a zone ID and a record ID, but you need to do it in three steps:

First, create a CKRecordZoneID with your zone ID and user:

let ckRecordZoneID = CKRecordZoneID(zoneName: "myZone", ownerName: CKOwnerDefaultName)

Then you can created a CKRecordID with your required record ID and specifying your CKRecordZoneID:

let ckRecordID = CKRecordID(recordName: recordIDString, zoneID: ckRecordZoneID)

Finally you can create the CKRecord using that record ID:

let ckRecord = CKRecord(recordType: myRecordType, recordID: ckRecordID)

Tags:

Ios

Cloudkit