If you want more then one perimeter pass then you can use a objc_setAssociatedObject
.
Any thing will be pass like Dictionary,Array,String,Int.
import ObjectiveC
extension UIButton {
private struct AssociatedKeys {
static var WithValue = "KeyValue"
}
@IBInspectable var withValue: String? {
get {
return objc_getAssociatedObject(self, &AssociatedKeys.WithValue) as? String
}
set {
if let newValue = newValue {
objc_setAssociatedObject(
self,
&AssociatedKeys.WithValue,
newValue as NSString?,
objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN
)
}
}
}
}
You need to use above extension:-
import ObjectiveC
button.tag = numbers[index];
button.addTarget(self, action: #selector(ViewController.buttonClicked(_:)), forControlEvents:UIControlEvents.TouchUpInside)
//set velue
button.withVelue = "1,2,3,4"
func buttonClicked(sender: UIButton){
print(sender.withVelue)
}