DavidK DavidK - 7 months ago 39
iOS Question

“Unrecognized selector sent to instance” swift

I keep getting a “Unrecognized selector sent to instance” in the

function when ever I press the button. I have no idea what I might be doing wrong.

@IBAction func addButtonDidTouch(_ sender: AnyObject) {
let alert = UIAlertController(title: "Grocery Item",
message: "Add an item to the list",
preferredStyle: .alert)

let saveAction = UIAlertAction(title: "Save",
style: .default) { action in
guard let textField = alert.textFields?.first,
let text = textField.text else { return }

let listItem = ListItem(name: text, addedByUser: self.user.email, completed: false)

let listItemRef = self.ref.child(text.lowercased())


the whole error im getting is

[UITableViewController addButtonDidTouch:]: unrecognized selector sent
to instance 0x7fba30612ce0


In your storyboard you have not set the class of this UITableViewController subclass. In IB, select the view controller, then visit the third tab over in the inspector. You need to set the Class to be your class.

I can tell because the error refers to UITableViewController not your custom subclass.