I can't figure out why but my app keeps crashing when ever I try to save a CKRecord in my data base and I get this error message, "terminating with uncaught exception of type CKException." Any input will be much appreciated. Heres my code:
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("")
}
}
})
}
}
There is a space in your recordType. You could replace this by something else.
You do have to be aware that in production you are not allowed to create a new recordType. All recordTypes must already exist (created on development). So all different values of realCurrentCountry have to be created on development.