我找不到会根据用户找到任何CKRecord的recordName字符串。我想获取记录,修改它,然后将其保存回云端。我可以做到这一点,但一次只有一条记录。如果我切换用户我的项目崩溃,因为recordName:对新用户不起作用。
if userLoad() {
let newInfo = CKRecordID(recordName: "212F4229-67B3-469D-AF4A-B9A693512AD2")
database.fetch(withRecordID: newInfo) { (record, Error) in
record?["username"] = self.textField1.text as CKRecordValue?
record?["type"] = self.textField2.text as CKRecordValue?
record?["hours"] = self.textField3.text as CKRecordValue?
self.database.save(record!, completionHandler: { (record, error) in
if error != nil{print("error on info")
} else {print("saved new info")}
})
}} else {print("no user")}
self.performSegue(withIdentifier: "account4", sender: self)
}