In Cocoa menu items behave a lot like controls. For example, menu items can send an action to a target object. Unlike controls, which normally talk to specific controller objects, menu commands are usually handled by an application's current selection. For example, the Copy command will copy the information from the selected control, regardless of which control is selected. In either case you connect menus using the same kinds of techniques you've seen earlier in this chapter.
In the following Try It Out, you build Slide Master's menu bar. Most of Slide Master's custom interface is meant to be handled by the slide show document. You configure the menus in three steps:
First, you design the menus in Interface Builder, and connect them to custom actions in the nib file's First Responder instance.
Then, you declare an application delegate in your MainMenu nib file and write code in Xcode to handle one of the menu items.
Finally, you implement the menu actions in a Slide Show document.
22.214.171.124. Try It Out: Connecting Menus to the First Responder
In Xcode, double-click the MainMenu nib file. The nib file opens in Interface Builder.
Rename the NewApplication menu to Slide Master. Also change the other occurrences of NewApplication in the Slide Master and Help menus to Slide Master.
Add an Import menu item to the File menu, as shown in Figure 8-28.
Figure 8.28. Figure 8-28
Drag the Submenu item from the Menus palette and insert it into the main menu bar between ...
With Safari, you learn the way you learn best. Get unlimited access to videos, live online training,
learning paths, books, interactive tutorials, and more.