I have a countdown timer. When it hits 0 secs, the timer is repeating until I press a stop button, but when I leave the viewcontroller without pressing the stop button, it's in the background, and when I go back to countdownViewController it won't stop.
How do I kill it when I exit viewcontroller without pressing the stop button?
Swift 4.2
I guess you have stopped the countdown timer on click of the Stop button. You can do the same coding in viewcontroller's viewDidDisappear method:
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
// Put the same code which works on Stop button click
}
I hope this helps.