In my UITableViewCell I have a button. And I want to add action to it by passing multiple parameters in cellForRowAtIndexPath method.
Easy!
1: Subclass UIButton:
class IndexPathCellButton: UIButton {
var indexPath:NSIndexPath?
}
2: Set your value:
...
cell.indexPathButton.addTarget(self, action: #selector(LocationSearchViewController.cellOptionButtonClick(_:)), forControlEvents: .TouchUpInside)
cell.indexPathButton.indexPath = indexPath // Your value
...
3: Retrieve your value:
@objc private func cellOptionButtonClick(sender: IndexPathCellButton) {
print(sender.indexPath)
}