If you want to send additional parameters to the buttonClicked method, for example an indexPath or urlString, you can subclass the UIButton:
class SubclassedUIButton: UIButton {
var indexPath: Int?
var urlString: String?
}
Make sure to change the button's class in the identity inspector to subclassedUIButton. You can access the parameters inside the buttonClicked method using sender.indexPath
or sender.urlString
.
Note: If your button is inside a cell you can set the value of these additional parameters in the cellForRowAtIndexPath method (where the button is created).