In my cellFoRowAtIndexPath
I want to add a function on a button that belongs to the cell.
In my cellFoRowAtIndexPath
I have added this code.
cell.acceptBtn.addTarget(self, action: "acceptRequest", forControlEvents: .TouchUpInside)
And then I have this function here.
func acceptRequest(sender: UIButton) {
println("hello");
}
When I run the project and click the button on that cell I get a
Terminating app due to uncaught exception 'NSInvalidArgumentException' unrecognized selector sent to instance
Something to note is I have another button that I used the same exact way called declineRequest
which works perfectly fine.
Try the following:
… noting that it is
"acceptRequest:"
and not"acceptRequest"
. The latter implies that the function has no parameters.