O'Reilly logo

Learning Cocoa by Apple Computer Inc

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

Set Up Timers

One of To Do’s features is the capability for notifying users of items with impending due times. Users can specify various intervals before the due time for these notifications, which take the form of a message in an Alert window. In this section you will implement the notification feature of To Do. In the process you’ll learn the basics of creating, setting, and responding to timers.

Here’s how it works. Each ToDoItem with a When to Notify switch (other than Do Not Notify) selected in the Info window—and hence has a positive secsUntilNotify value—has a timer set for it. If a user cancels a notification by selecting Do Not Notify, the document controller invalidates the timer. When a timer fires, it invokes a method that displays the Alert window, selects the Do Not Notify switch, and sets secsUntilNotify to 0.

Implementing the timer feature takes place entirely in Project Builder.

Set a Timer for an Item

An item’s timer must be reset whenever its day, due time, notify time, or status changes. The item’s accessor methods could handle this, but there are times when several instance variables get set in sequence. It would be better not to reset the timer at each individual change in this case, so instead a separate update step, setTimerForItem:, is implemented in ToDoDocument.

All timer-related values for a document’s selected ToDoItem can be set and modified by InfoWindowController. Following each modification, InfoWindowController sends the document a selectedItemModified ...

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