Timers

NSTimer is used to perform operations after a specified delay. An NSTimer can also be set to repeat, to perform a set of operations over and over again after a specified delay.

The easiest way to create an NSTimer is using the class method scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:.

To create a repeating timer, set the repeats parameter to YES.

To stop an NSTimer, call its invalidate method.

If you want to pass parameters to the timer callback, you can store them in the userInfo dictionary.

As an alternative, you can use NSObject‘s performSelector:withObject:afterDelay: method.

Comments are closed.