My function is this and it is called with a "done" UIBarButtonItem.
@IBAction func done(sender: UIBarButtonItem) {
dismissViewControllerAnimated(true, completion: nil)
}
I have read multiple other questions/answers about a deleted instance or an old/extra connection in the Interface Builder or in the View Controller code. However, I only have this one function all properly connected without any extra lingering connections. How do I get rid of the "unrecognized selector sent to instance" error
Thanks in advance!
With the information provided in the question I suspect
There is unwanted connection left. To see that you can do:
1) Go to the IB and select the button.
2) Right click on the button and see all the actions. If you see any unwanted action delete it and try running again.
You can also do it programmatically
Set the target for UIBarButtonItem like this
var b = UIBarButtonItem(
title: "Continue",
style: .Plain,
target: self,
action: "sayHello:"
)
func sayHello(sender: UIBarButtonItem) {
}
If you dont want any parameters in the sayHello function, you can do it
var b = UIBarButtonItem(
title: "Continue",
style: .Plain,
target: self,
action: "sayHello"// Remove the colon
)
func sayHello() {
}
Let me know if it works for you