I'm using CoreData for keeping a local cache of records in CloudKit. When saving a new record, I do the following:
- Insert record to CoreData. I flag this record as not updated in CloudKit. Just in case my CKModifyRecordsOperation fails, I can still update it at a later time to CloudKit using this flag.
- Insert record to CloudKit using CKModifyRecordsOperation.
- Try fetching the ckRecordID of the record inserted in step #2. (That's where my logic fails as I'm not sure how I can achieve this). I do not have any other keys (reference) and wish to use only CKRecordID as a reference between CoreData and CloudKit.
- Update the ckRecordID (fetched in step #3) to CoreData.
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:
Here's my code: