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)
}
我应该在Checks
RecordZone中的Check
对象上保存一个profile
属性。当我触发此函数时,我收到以下错误:
<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's omited ...
我尝试了几件事情:
- 检查zoneID是否正确,结果是正确的。
- 在该方法中将zoneID硬编码为CKRecordZoneID对象。
- 在谷歌和SO上查找错误,但没有结果。
请注意,sharedstore.checksID
是一个实际的ID,而不是字符串,在应用程序启动时创建并获取所有记录区域。
如何解决这个错误?任何建议都将不胜感激。