I've the following code which is for editing my contact, but somehow I'm receiving this error: NSString is not a subclass of category. This is my code
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)
}
It's crashing on this line : contact?.category = categoryField.text Any help ?