Reputation: 11
I'm trying to set a parent on a CKRecord. Basically, a reminder is the child of a list. The list already exists on the server.
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
}
}
Every time I do this, I get the following error: [LogFacilityCK] Got a connection error for operation 28174DD7CAF85542: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.cloudd" UserInfo={NSDebugDescription=connection to service named com.apple.cloudd}
If I remove the setParent line, then the record is created successfully on the server. Am I doing something wrong?
Upvotes: 1
Views: 388
Reputation: 228
It is probably because the listID record is not yet saved to the cloud, therefore the cloud cannot set listID
as the parent of record
. Try saving both newly created records:
let modifyRecordsOp = CKModifyRecordsOperation(recordsToSave:[record, listID], recordsToDelete:nil)
Upvotes: 1