I have a "like button" and all the users use it at the same time. It should increment the value of like record in the cloud container by one, or decrease it by one. How can I guarantee that the update happens to the last version of the record? I mean what is the code in Swift 3 that can guarantee that every user will get the final value of the like record and apply the increment while other users send the same operation on the same record? Sorry I don't have code to show about this.
I read about CKErrorServerRecordChanged but I don't know how to use it in syntax. If you have an example for the code will be, it will be great.
I found it in Firebase. It is called transaction and it keeps tracking the record version until it applies the operation to the last version so it will not lose any of the user operation targeting that record.
Ok, not sure this is a cut'n'paste answer, but will give you a template to work with. It shows extensive error code handling, with an action next to the retry with the save action for example. You should be able work out how to do what you want to do with this code.