I have this piece of code:
func saveProfileForCheck(check: Check) {
let toSave = CKRecord(recordType: "Check", zoneID: sharedStore.checksID!)
let profile = check.profile as Profile!
toSave.setValue(NSString(format: "%i", check.closed), forKey: "closed")
toSave.setValue(check.date, forKey: "date")
toSave.setValue(NSString(format: "%i", check.paid), forKey: "paid")
toSave.setValue(CKReference(recordID: profile.dbRecordID, action: CKReferenceAction.DeleteSelf), forKey: "profile")
let operation = CKModifyRecordsOperation(recordsToSave: [toSave], recordIDsToDelete: [check.id])
operation.modifyRecordsCompletionBlock = { (savedRecords, deletedRecordIDs, error) in
if error != nil {
self.delegate?.cloudKitReturnedError(error!)
} else {
self.modifiedCheck(check, newRecord: savedRecords![0] as CKRecord )
}
}
privateDB.addOperation(operation)
}
It is supposed to save the property of the profile
object Check
in my Checks
RecordZone record . When I run this function, I get this error:
<CKError 0x7f8c2046d630: "Partial Failure" (2/1011); "Failed to modify some records"; uuid = EF4CCE3F-3CDB-4506-BA43-464D7D9BD0F6; container ID = "mycontainer"; partial errors: {
130BD962-295C-4601-9343-2E4F4014C8C7:(Checks:__defaultOwner__) = <CKError 0x7f8c2045c680: "Invalid Arguments" (12/2006); server message = "ZoneId provided doesn't match target zone">
... 1 "Batch Request Failed" CKError omited ...
}>
I have made several attempts:
- Checked if zoneID is really correct, namely.
- Hardcoded zoneID as a CKRecordZoneID object in a method.
- I looked at the error in google and SO, which has no result.
Keep in mind that this sharedstore.checksID
is the actual identifier instead of the line that is created when the application starts, when all recording zones are retrieved.
How can I solve this error? Any suggestion would be highly appreciated.