阅读背景:

保存信息Swift 2时,CloudKit总是遇到错误

来源:互联网 

I always run a error if i try to save a test information into CloudKit

如果我尝试将测试信息保存到CloudKit中,我总是会运行错误

my code is

我的代码是

   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")
        }
  }

My database look like

我的数据库看起来像

Could someone explain me what i m doing wrong?

有人可以解释一下我做错了什么吗?

1 个解决方案

#1


0  

override func viewDidLoad() {

override 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)
        }

    })

}

分享到: