Search code examples
ioscloudkit

Increment field value in a CKRecord variable without fetching?


I am curious is it somehow possible to increment a field value in a CKRecord variable without fetching? So on client I am not curious about the recent value, I just want to increase whatever be the value is. The reason, operation should be as quick and easy as possible, instead of two message 'stream', I want initiate only one.


Solution

  • Unfortunately you can not. You have to read, change and then write the record. Make sure that you use the CKModifyRecordsOperation and leave the savePolicy to CKRecordSaveIfServerRecordUnchanged If you get an error then you could try read and write the record again.