Reputation: 2237
I want to use a selector, but I need to pass in the arguments I understand the syntax follows:
#selector(class.method(_:paramName:))
but i need to actually pass in parameters. How do I do this?
Here's my attempt:
exploreTap = UITapGestureRecognizer(target: self, action: #selector(MainViewController.showViewWithIdentifier(_:exploreView,id:"explore")))
Upvotes: 1
Views: 3356
Reputation: 130191
You cannot pass parameters to selectors, selector is just a method name, nothing else. You are not calling the method so you cannot pass parameters. Just call the necessary code inside your tap handler.
func onTap() {
MainViewController.showViewWithIdentifier(exploreView, id:"explore")
}
and then
UITapGestureRecognizer(target: self, action: #selector(onTap))
Upvotes: 2