我有以下代码用于编辑我的联系人,但不知何故我收到此错误:NSString不是类别的子类。这是我的代码
func editContact() {
let index = pickerView.selectedRowInComponent(0)
let fetchedObject = self.fetchedResultsController_cat.objectAtIndexPath(NSIndexPath(forRow: index, inSection: 0)) as! Category
contact?.name = nameField.text
contact?.phone = phoneField.text
contact?.email = emailField.text
contact?.photo = UIImageJPEGRepresentation(imageHolder.image, 1)
contact?.category = categoryField.text
context?.save(nil)
var alert = UIAlertController(title: "Notification", message: "Contact edited", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
这一行正在崩溃:联系人?.category = categoryField.text 有什么帮助吗?