[Solved] How to connect a seconds timer to a minutes timer in Swift? [closed]


I would not use separate timers. Have a seconds timer that fires once a second.
It sounds like you want a count-down timer. So…

Record the time when the timer starts using code like this:

let secondsToEnd = 60*5
let startInterval =  NSDate.timeIntervalSinceReferenceDate()
let endInterval = startInterval + Double(secondsToEnd)

Then in your timer code:

let remainingSeconds = Int(endInterval - NSDate.timeIntervalSinceReferenceDate())
let minutes = remainingSeconds/60
let seconds = remainingSeconds%60

Display the minutes and seconds values however you need to.

NSTimers will sometimes miss a firing if the app is busy when the timer should have gone off, and are not super-accurate. The above code will always calculate the real remaining amount of time, regardless of the timer you use to display that info and any inaccuracy in that timer.

solved How to connect a seconds timer to a minutes timer in Swift? [closed]