Objective-C Language NSTimer Invalidating a timer


Example

[timer invalidate];
timer = nil;

This will stop the timer from firing. Must be called from the thread the timer was created in, see Apple's notes:

You must send this message from the thread on which the timer was installed. If you send this message from another thread, the input source associated with the timer may not be removed from its run loop, which could prevent the thread from exiting properly.

Setting nil will help you next to check whether it's running or not.

if(timer) {
    [timer invalidate];
    timer = nil;
}

//Now set a timer again.