Interface Builder

Because it is so graphically oriented, Aqua applications adhere to a very passive runtime model. In fact, a typical Mac OS X application spends most of its time running in an idle loop, waiting for some sort of user input, such as a keypress or a mouseclick onto one of its buttons. Through the Interface Builder application, you specify the onscreen controls that your application will have and tie these into handler methods within your code.

Interface Builder helps you generate .nib files, which are serialized versions of Cocoa application elements. Typically, an application has one .nib file for every window that its interface contains. A very simple text-editing application, for example, might have one such file for its document window (containing the text view in which the user actually types), another for the application’s Preferences window, and a third for its About panel. All but the most minimal applications also contain a .nib that holds its menu-bar menus (including its application menu and everything to the right of it, as described in Section 1.4 in Chapter 1).

Through Interface Builder, you can build these windows by dragging template windows, controls, and views off of palettes, as shown in Figure 15-5. You can then establish connections between parts of the window and classes belonging to your application.

Building a window with Interface Builder

Figure 15-5. Building a window with Interface ...

Get Mac OS X Panther in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.