I have a NSTimer
object that I need to invalidate if a user taps on a button or if they exit a view.
So I have:
[myNSTimer invalidate];
inside my button handler and inside viewWillDisappear
. If user taps on a button and then exists a view the app throws an exception because myNSTimer
has already been invalidated.
What I need to do in the viewWillDisappear
method is check if the myNSTimer
has been invalidated or not. How do I do that?
I've tried:
if(myNSTimer != nil)
[myNSTimer invalidate];
but that didn't work.