I'm using CoreData for keeping a local cache of records in CloudKit. When saving a new record, I do the following:
What would be the best logic to solve the above? Thank you for your time and responses.
I solved this by creating a CKRecordID locally and updating it in CloudKit. Below is the quote from apple documentation:
To assign a custom record ID to a new record, you must create the CKRecordID object first. You need to know the intended name and zone information for that record, which might also require creating a CKRecordZone.ID object. After creating the record ID object, initialize your new record using its init(__recordType:recordID:) method.
Here's my code:
let zone = CKRecordZone(zoneName: Schema.Zone.group)
let uuid = NSUUID()
let recordType = Schema.RecordType.group
let recordName = uuid.uuidString
let recordID = CKRecordID(recordName: recordName, zoneID: zone.zoneID)
let newRecord = CKRecord(recordType: recordType, recordID: recordID)