I cant seem to get certain records to modify in my public database. The error is
Error saving record <CKRecordID: XXXXXXX; recordName=XXXXXX, zoneID=_defaultZone:defaultOwner> to server: WRITE operation not permitted
I don't understand why it says "Write not permitted" because I have all the correct Security Roles checked off in the dashboard. I also confirmed that it is signed into Icloud before I try to modify the record.
This is the relevant code:
// MARK: - Modify Updates in Cloudkit
static func modifyUpdates(item: pushNote, completion: @escaping (Result<pushNote, Error>) ->
()) {
guard let recordID = item.recordID else { return }
CKContainer.default().publicCloudDatabase.fetch(withRecordID: recordID) { (record, err) in
DispatchQueue.main.async {
if let err = err {
completion(.failure(err))
return
}
guard let record = record else { return }
record["updates"] = item.updates as CKRecordValue
CKContainer.default().publicCloudDatabase.save(record) { (record, err) in
DispatchQueue.main.async {
if let err = err {
completion(.failure(err))
return
}
guard let record = record else { return }
let id = record.recordID
guard let updts = record["updates"] as? [String] else { return }
guard let boss = record["bossID"] as? String else { return }
let element = pushNote(recordID:id, bossID: boss, updates : updts)
completion(.success(element))
}
}
}
}
}
Saving Security Role changes takes time to kick it. Like 10min for me. I recommend not clicking Save too many times. Log out and back in to see if it is actually saved.