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
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
Implementing the timer feature takes place entirely in Project Builder.
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