Chapter 21. NSTimer

An instance of NSButton has a target and a selector (the action). When the button is clicked, the action message is sent to the target. Timers work in a similar way. A timer is an object that has a target, a selector, and a delay, which is given in seconds (Figure 21.1). After the delay, the selector message is sent to the target. The timer sends itself as an argument to the message. The timer can also be set to send the message repeatedly.

NSTimer

Figure 21.1. NSTimer

To play with timers a bit, you will create a typing tutor application. The application will have two BigLetterView objects. One will display what the user should type, and ...

Get COCOA PROGRAMMING FOR MAC OS X SECOND EDITION now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.