Coredata转发问题

时间:2015-09-28 08:17:41

标签: ios swift core-data downcast

我有以下代码用于编辑我的联系人,但不知何故我收到此错误: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 有什么帮助吗?

0 个答案:

没有答案