Timer doesn't quit

I have a timer that runs ok. However, when I try to stop the timer, neither function is executed. The code is as follows:

`   func viewWillDisappear(animated: Bool) {
        super.viewWillDisappear(animated)
        print(#function)
        menuTimer = nil
        menuTimer?.invalidate()
        
       
    }
    
    override func viewDidDisappear(_ animated: Bool) {
        print(#function)
        super.viewDidDisappear(animated)
        menuTimer = nil
        menuTimer?.invalidate()
        
    }

Is this a known issue or am i doing something wrong.

Look closer at these lines:

menuTimer = nil
menuTimer?.invalidate()

When executed in that order, would they actually invalidate the timer?

Thanks for your reply! It makes sense, however the two functions are still not called.

Got it. I forgot to override viewWillDisappear

Timer doesn't quit
 
 
Q