SwiftUi CloudKit 记录修改保存失败 "WRITE operation not permitted"
SwiftUi CloudKit Record Modify Failed to Save "WRITE operation not permitted"
我似乎无法在我的 public 数据库中修改某些记录。错误是
Error saving record <CKRecordID: XXXXXXX; recordName=XXXXXX, zoneID=_defaultZone:defaultOwner> to server: WRITE operation not permitted
我不明白为什么它说“不允许写入”,因为我在仪表板中勾选了所有正确的安全角色。在尝试修改记录之前,我还确认它已登录到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))
}
}
}
}
}
保存安全角色更改需要一些时间才能完成。对我来说就像 10 分钟。我建议不要多次点击保存。注销并重新登录,看看是否真的保存了。
我似乎无法在我的 public 数据库中修改某些记录。错误是
Error saving record <CKRecordID: XXXXXXX; recordName=XXXXXX, zoneID=_defaultZone:defaultOwner> to server: WRITE operation not permitted
我不明白为什么它说“不允许写入”,因为我在仪表板中勾选了所有正确的安全角色。在尝试修改记录之前,我还确认它已登录到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))
}
}
}
}
}
保存安全角色更改需要一些时间才能完成。对我来说就像 10 分钟。我建议不要多次点击保存。注销并重新登录,看看是否真的保存了。