如果我尝试将测试信息保存到CloudKit
,我总是会出错
我的代码是
super.viewDidLoad()
let publicDB = CKContainer.defaultContainer().publicCloudDatabase
let todoRecord = CKRecord(recordType: "cloudKit_TESTSTATUS")
todoRecord.setValue("TEST DATA", forKey: "status")
publicDB.saveRecord(todoRecord) { savedRecord, error in
print("error")
}
}
我的数据库看起来像
有人可以解释我在做什么错吗?
最佳答案
覆盖func viewDidLoad(){
let container = CKContainer.defaultContainer()
let publicData = container.privateCloudDatabase
let todoRecord = CKRecord(recordType: "cloudKit_TESTSTATUS")
todoRecord.setValue("TEST DATA", forKey: "status")
publicData.saveRecord(todoRecord, completionHandler: { record, error in
if error != nil {
print(error)
}
})
}