Now it’s time to add functionality to the ToDoDocument class to facilitate synchronizing data display with an Info window. The Info window must display information about the ToDoItem currently selected in the ToDoDocument and update its view if a new document is opened (or brought to the front). Also, the ToDoDocument must update its display when an item is modified in the Info window. In this section you’ll make this communication work.
where ToDoItems are added, removed, or modified, so you must let
the Info window know when there’s a change in the current ToDoItem.
Modify the method to post a
the object related to the notification.
InfoWindowController.h. While you’re here,
SelectionNotifyMatrix.h as well, to pick up
Add the following code to the
/* ... */ [self updateChangeCount:NSChangeDone]; [[NSNotificationCenter defaultCenter] postNotificationName: ToDoItemChangedNotification object:selectedItem userInfo:nil];
InfoWindowController.m and modify the
windowDidLoad method to register the
InfoWindowController as an observer of the
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectedItemChanged:) name:ToDoItemChangedNotification object:nil];
Add the definition of the ...