1

How can I create a seconds counter which I can stop it and then resume from where I stopped it?

I've create this timer:

func countSeconds() {

    secondsTimer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(addSeconds), userInfo: nil, repeats: true)
}

@objc func addSeconds() {
    seconds += 1
}

but with invalidate method I don't resume from where I stopped the timer.

Pietro P.
  • 185
  • 1
  • 1
  • 7
  • You cant resume the timer where you paused. Just store the current recorded time. Create a new timer and add the time to it https://stackoverflow.com/questions/29406256/how-can-i-pause-and-resume-nstimer-scheduledtimerwithtimeinterval-in-swift – arvidurs Oct 17 '17 at 17:01

0 Answers0