I have a button that I add a target to, the selector contain a variable.
Can I add the variable into the selector without receiving an error?
Thank you in advance.
//this cause a selector error when run
self.save.addTarget(self, action: #selector(self.saveItems(dataToSave)), forControlEvents: .TouchUpInside)
Create an additional function to use it as an action selector
argument
func helperFunc() {
self.saveItems(dataToSave)
}
And then add it
self.save.addTarget(self, action: #selector(self.helperFunc), forControlEvents: .TouchUpInside)