You can either change the IBAction signature by specifying its parameter. Optional, like this:
@IBAction func doSomeTask(sender: UIButton?) { // code }
and then call it with nil as an argument:
doSomeTask(nil)
Or you can use IBAction as a wrapper for a real function:
func doSomeTaskForButton() { // ... } @IBAction func doSomeTask(sender: UIButton) { doSomeTaskForButton() }
means you can call doSomeTaskForButton() from anywhere.
Moritz
source share