我正在尝试在CKRecord上设置父级。基本上,提醒是列表的孩子。该列表已存在于服务器上。
let record = CKRecord(recordType: "Reminder", recordID: recordID)
let listID = CKRecordID(recordName: listName, zoneID: listZoneID)
record["title"] = "Test TODO"
record.setParent(listID)
let modifyRecordsOp = CKModifyRecordsOperation(recordsToSave:[record], recordsToDelete:nil)
modifyRecordsOp.modifyRecordsCompletionBlock = { (_, _, error) in
guard error == nil else {
print(error)
return
}
}
每次我这样做,都会收到以下错误: [LogFacilityCK]操作28174DD7CAF85542出现连接错误:错误域= NSCocoaErrorDomain代码= 4097“连接到名为com.apple.cloudd的服务”UserInfo = {NSDebugDescription =连接到名为com.apple.cloudd的服务}
如果删除setParent行,则会在服务器上成功创建记录。我做错了吗?
答案 0 :(得分:1)
可能是因为listID记录尚未保存到云端,因此云无法将listID
设置为record
的父级。尝试保存两个新创建的记录:
let modifyRecordsOp = CKModifyRecordsOperation(recordsToSave:[record, listID], recordsToDelete:nil)