Reputation: 1221
I have a custom UITableViewDelegate, as the following
class CusinePreferencesTableView: NSObject, UITableViewDelegate, UITableViewDataSource {
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(CellIdentefiers.oneCusinePreferencesCell.rawValue, forIndexPath: indexPath) as! OneCusinePreferencesTableViewCell
//do bla bla bla with the cell
cell.leftButton.addTarget(self, action: "cusineClicked:", forControlEvents: .TouchDown)
cell.rightButton.addTarget(self, action: "cusineClicked:", forControlEvents: .TouchDown)
cell.setNeedsDisplay()
return cell
}
my cell has two buttons, and as you see, I'm setting actions for them.
I'm getting exception states that unrecognized selector sent to instance 0x7fa660ecbfa0
I tried to put the
func buttonClicked(sender: PreferenceButton){
// do bla bla bla
}
in both the CusinePreferencesTableView
and inside the UIViewController that has an outlet for the UITableView, and which is using CusinePreferencesTableView as its delegate, but I kept with that exception having it
Help please
Upvotes: 0
Views: 28
Reputation: 7637
In the CusinePreferencesTableView
add the button's action
func cusineClicked(sender: PreferenceButton){
print("action triggered")
}
The action name that was set when target was added to the button is different from action (different names) you have actually implemented in the class.
Upvotes: 3