Introduction to Timers
A timer provides a way to perform a delayed action or a periodic action. The timer waits until a certain time interval has elapsed and then fires, sending a specified message to a specified object. For example, you could create a timer that sends a message to a controller object, telling it to update a particular value after a certain time interval.
At a Glance
Timers work in conjunction with
NSRunLoop objects. As a result, they don’t provide a real-time mechanism—their accuracy is limited.
For more about timers in general, see “Timers.”
There are several aspects to using a timer. When you create a timer, you must configure it so that it knows what message to send to what object when it fires. You must then associate it with a run loop so that it will fire—some of the creation methods do this for you automatically. Finally, if you create a repeating timer, you must invalidate it when you want it to stop firing.
To learn more about using timers, see “Using Timers.”