O'Reilly logo

Beginning Mac OS® X Programming by Drew McCormack, Michael Trent

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

8.11. Application Preferences

Cocoa doesn't provide any special support for application preference windows, other than reserving a menu item for Preferences in new application nib files. You can simply apply the techniques and short-cuts you learned in earlier examples to build a window with controls, record the values when they change, and tell other parts of the application that they need to respond to that change. Cocoa Bindings do a very good job of managing this kind of problem.

In this example, you add a simple preference window to Slide Master, shown here in Figure 8-35. This window runs as a modal dialog just to keep things simple. You will use Cocoa Bindings to manage the values of the controls in your window, and observe the changes as they happen.

Figure 8.35. Figure 8-35

You complete the following Try It Out in two steps:

  • First, you build the new user interface, including binding these controls with Cocoa Bindings.

  • Then, you complete the custom code required to run the window modally and interpret the values.

8.11.1.

8.11.1.1. Try It Out: Creating a Preference Window Interface
  1. Open Slide Master's MainMenu nib file in Interface Builder.

  2. Add an orderFrontPreferencePanel: action to the First Responder. Remember you can edit the First Responder instance from the Classes tab.

  3. Connect your menu bar's Slide MasterPreferences menu item to the First Responder's orderFrontPreferencePanel ...

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