iOS Invalidating a timer


Example

Swift

timer.invalidate()

Objective-C

[timer invalidate];

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.

Notes: Once timer has been invalidated, its impossible to fire same invalidated timer.Instead you need to initialise the invalidated timer again and trigger fire method.