O'Reilly logo

Objective-C Programming: The Big Nerd Ranch Guide by Mikey Ward, Aaron Hillegass

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Target-action

Timers use a target-action mechanism. You create a timer with a time interval, a target, and an action. After the interval has elapsed, the timer sends the action message to its target.

You are going to add an instance of NSTimer to your program. Every two seconds, the timer will send the action message to its target. You will also create a class named BNRLogger. An instance of that class will be the timer’s target.

Figure 27.1  BNRLogger is the target of the NSTimer

BNRLogger is the target of the NSTimer

Create a new file: an Objective-C class called BNRLogger that is a subclass of NSObject.

In BNRLogger.h, declare a property that holds a date, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required