Building the Calculator’s User Interface
The
MainMenu.nib
file created by PB and opened in IB above is called, aptly enough, a
nib file
(nib stands for NeXT Interface
Builder — a holdover from the pre-Apple life of this
development environment). A nib file stores information about all of
the user interface objects in your program, including the windows,
controls, and menus; the connections between those objects; and some
other objects that IB knows about. When you compile and link the
application you are building, the application’s nib
file (or files, if the program uses more than one) gets bundled
together with the program’s executable code and
stored in a package, or app
wrapper
, folder. This folder has a
.app
extension and
looks like an executable application in the Finder.
The nib files are stored in an undocumented Cocoa proprietary binary format. Fortunately, it doesn’t need to be documented — all of the nib-file management is done by IB. IB is basically a nib editor: when it opens a nib file, it reads the specifications and displays the associated objects. After you make your modifications to the program, IB writes out a new nib file, replacing the old one.
Now that we’ve created the project, we’ll add and customize the windows, panels, and menus needed for our Calculator’s user interface.
Customizing the Main Window
The main window in the Calculator’s interface, currently titled “Window”, doesn’t look anything like a calculator: it’s the wrong shape, it shouldn’t have ...
Get Building Cocoa Applications: A Step by Step Guide 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.