23 NSTimer

As you learned in Chapter 5, controls have a target and an action. The target is a reference to another object; the action is a selector (essentially the name of the method to be called on the target). When a button is clicked, the action method is called on the target.

Timers work in a similar way. A timer is an object that has a target, a selector, and an interval, which is given in seconds (Figure 23.1). After the interval has elapsed, the action is called on the target. The sender in this case is the timer itself. The timer can also be set to send the message repeatedly.

Figure 23.1  NSTimer

NSTimer

To play with ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.