17.11 · Records, system fields and CKError handling

CloudKit sync code is mostly error handling: knowing which record state you hold and what each failure asks of you.

Mental model. A CKRecord is a dictionary plus server-owned system fields; a CKError names the next step.

Records

Fields, system fields, parents and zones.

  1. What is in a CKRecord, why archive its system fields, and what are the zone rules for references and parents? 17.11.1 · L5
    A record is a typed key-value dictionary (allKeys() shows the fields, changedKeys() the ones not yet sent) plus system fields managed by the server: record id…

Errors

Partial failures, retries and conflicts.

  1. How should a sync layer react to CKError codes: partial failures, retry-after, conflicts and expired tokens? 17.11.2 · L5
    Operations report failure as CKError; branch on code. A batch usually fails as .partialFailure (code 2), whose partialErrorsByItemID holds one CKError per…

More in System frameworks