我似乎无法在我的公共数据库中修改某些记录。错误是“错误保存记录 <CKRecordID: XXXXXXX; recordName=XXXXXX, zoneID=_defaultZone: defaultOwner > to server: WRITE operation not allowed”。我不明白为什么它说不允许写入,因为我在仪表板中检查了所有正确的安全角色。在我尝试修改记录之前,我还确认它已登录到 Icloud。这
// 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))
}
}
}
}
}