I have timerRunner()
function that runs when button is clicked:
func timerRunner() {
timer = Timer.scheduledTimer(timeInterval: 1.0, target: target.self, selector: (#selector(self.timeUpdater)), userInfo: nil, repeats: true)
}
Selector of Timer.scheduledTimer
is selected as following:
@objc func timeUpdater() {
counter = counter + 1
timerLabel.text = secondConverter(seconds: counter)
}
But this is an error message I get:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_SwiftValue timeUpdater]: unrecognized selector sent to instance '
target.self
in your code? Why not simplyself
as you use#selector(self.timeUpdater)
? - OOPer