以 CKException 类型的未捕获异常终止
terminating with uncaught exception of type CKException
我不明白为什么,但每当我尝试在我的数据库中保存 CKRecord 时,我的应用程序总是崩溃,并且我收到此错误消息,"terminating with uncaught exception of type CKException."任何输入将不胜感激。这是我的代码:
func saveCountryMood(countryToSave:String) {
// Create CK record
let newRecord:CKRecord = CKRecord(recordType: realCurrentCountry)
newRecord.setValue(countryToSave, forKey: "Country")
// Save record into public database
if let database = self.publicDatabase {
database.saveRecord(newRecord, completionHandler: { (record:CKRecord!, error:NSError!) -> Void in
// Check for error
if error != nil {
// There was an error
NSLog(error.localizedDescription)
}
else {
// There was no error
dispatch_async(dispatch_get_main_queue()) {
// Refresh table
self.retrieveCountryMoods("")
}
}
})
}
}
您的记录类型中有一个 space。你可以用别的东西代替它。
您必须知道在生产中您不能创建新的 recordType。所有记录类型必须已经存在(在开发时创建)。因此,必须在开发时创建 realCurrentCountry 的所有不同值。
我不明白为什么,但每当我尝试在我的数据库中保存 CKRecord 时,我的应用程序总是崩溃,并且我收到此错误消息,"terminating with uncaught exception of type CKException."任何输入将不胜感激。这是我的代码:
func saveCountryMood(countryToSave:String) {
// Create CK record
let newRecord:CKRecord = CKRecord(recordType: realCurrentCountry)
newRecord.setValue(countryToSave, forKey: "Country")
// Save record into public database
if let database = self.publicDatabase {
database.saveRecord(newRecord, completionHandler: { (record:CKRecord!, error:NSError!) -> Void in
// Check for error
if error != nil {
// There was an error
NSLog(error.localizedDescription)
}
else {
// There was no error
dispatch_async(dispatch_get_main_queue()) {
// Refresh table
self.retrieveCountryMoods("")
}
}
})
}
}
您的记录类型中有一个 space。你可以用别的东西代替它。
您必须知道在生产中您不能创建新的 recordType。所有记录类型必须已经存在(在开发时创建)。因此,必须在开发时创建 realCurrentCountry 的所有不同值。