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
where 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.2).
Through Interface Builder, build these windows by dragging template
windows, controls, and views off of palettes, as shown in Figure 15-5. Then establish connections between parts of
the window and classes belonging to your application. Normally, you
define a special class known as a Window
Controller
for every window (and therefore
every .nib
file), and supply it with two types
of data: outlets, which are ...
Get Mac OS X in a Nutshell 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.