I try to implement a double functionality on a button of a navigation bar, for this I have implemented this code
class ViewController: UIViewController {
@IBOutlet weak var txtBuscar: UITextField!
@IBOutlet weak var btnNuevoItem: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
navigationController?.navigationBar.barStyle = UIBarStyle.blackTranslucent
navigationController?.navigationBar.barTintColor = UIColor(red:0.02, green:0.63, blue:0.67, alpha:0.20)
tabBarController?.tabBar.barTintColor = UIColor(red:0.02, green:0.63, blue:0.67, alpha:0.20)
tabBarController?.tabBar.tintColor = UIColor.white
}
@IBAction func btnNuevoItem_onClick(sender: Any, forEvent event: UIEvent)
{
guard let touch = event.allTouches?.first else { return }
if touch.tapCount == 1 {
Mensaje().mensajeSinFuncion(controller: self, texto: "1 click")
} else if touch.tapCount == 0 {
Mensaje().mensajeSinFuncion(controller: self, texto: "long click")
}
}
}
The problem is the argument forEvent of method btnNuevoItem_onClick because removing it does not give me any error, the error mentioned is this
App.ViewController btnNuevoItem_onClick:]: unrecognized selector sent to instance 0x7fe36990be00
2017-10-19 11:17:05.675036-0500 App[4474:644996] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [App.ViewController btnNuevoItem_onClick:]: unrecognized selector sent to instance 0x7fe36990be00'
Any idea of controlling this error or any other way to achieve it?