cloudkit - Can't retrieve CKRecords to resolve conflicts on CKErrorCodeServerRecordChanged in CKModifyRecordsOperation -
i ran problem when trying handle errors when doing batch operations on records in cloudkit.
i extracting dictionary containing partial errors, can iterate over. however, not able records needed resolve conflict ckerrorcodeserverrecordchanged. according docs should able 3 records out of dictionary:
- ckrecordchangederrorserverrecordkey
- ckrecordchangederrorancestorrecordkey
- ckrecordchangederrorclientrecordkey
thank hints on doing wrong here.
func pushrecordchangesforzoneid(recordzoneid: ckrecordzoneid) { // ... modifyrecordsoperation.modifyrecordscompletionblock = { (savedrecords, deletedrecordids, error) -> void in if (error != nil) { if error.code == ckerrorcode.partialfailure.rawvalue { if let errordict = error.userinfo?[ckpartialerrorsbyitemidkey] as? [ckrecordid : nserror] { (recordid, partialerror) in errordict { if partialerror.code == ckerrorcode.serverrecordchanged.rawvalue { if let userinfo = partialerror.userinfo { let serverrecord = userinfo[ckrecordchangederrorserverrecordkey] as? ckrecord // serverrecord nil } } } } } } }
}
additional information: when print description of userinfo dict of partial error (partialerror.userinfo) doesn’t contains other ckrecords:
[nsdebugdescription: ckinternalerrordomain: 2037, nslocalizeddescription: error saving record <ckrecordid: 0x7fb41bf7e640; da39fe08-ab0b-4f07-a42e-f5732b114706:(userdata:__defaultowner__)> server: protection data didn't match, nsunderlyingerror: <ckerror 0x7fd89a92d370: "unknown error" (2037)>]
the description of source error's dictionary (errordict) looks (and can dictionary containing recordids , partial errors out via ckpartialerrorsbyitemidkey):
[<ckrecordid: 0x7fb5bb88afa0; c1575083-f992-448a-8d77-d62c4a42d696:(userdata:__defaultowner__)>: <ckerror 0x7fb5b961c6a0: "batch request failed" (22/2024); server message = "atomic failure"; uuid = 1e4c0fd5-ec10-4071-b277-102a9f1b0e5e; container id = "icloud.net.neverthesamecolor.atsumeru">, <ckrecordid: 0x7fb5bb848ad0; da39fe08-ab0b-4f07-a42e-f5732b114706:(userdata:__defaultowner__)>: <ckerror 0x7fb5b9653060: "server record changed" (14/2037); "error saving record <ckrecordid: 0x7fb41bd9ca50; da39fe08-ab0b-4f07-a42e-f5732b114706:(userdata:__defaultowner__)> server: protection data didn't match">]
the docs it's custom zone feature only.
edit 21st jan 2016: it's working me right in default zone , public database. big change before.
Comments
Post a Comment