Adding Objects to Your Application

In this section, we’ll customize our new application’s main window, “Window”. It’s wonderful that IB automatically provides every new application with this window, but it’s rarely the right size. Sometimes it’s too small; usually it’s too big. Fortunately, we can easily resize the window as we would any Mac OS X window.

  1. Resize the window titled “Window” to a height of about one inch and a width of about three inches.

Notice that you don’t need to know the exact height and width of this window to set its size; you simply resize it visually and you’re done (remember, you’re building an application here). This is a good example of the basic philosophy of IB — graphical things are best done graphically. This philosophy is at the heart of Cocoa’s ease of programming. (On the other hand, you can resize the window to precise dimensions using the NSWindow Info dialog, if necessary.)

Adding a Button Object to Your Window

The IB Palettes window near the upper-right corner of the screen contains seven (or more) palettes of objects that can be dragged into your application. By clicking one of the selector buttons in the toolbar near the top of the Palettes window, you can choose which palette is visible. The Palettes window is a multi-view window, in which one of several different views (panes) can be displayed depending on your selection of a tab, pop-up menu item, or other item. The Nib File window is also a multi-view window, but its different views ...

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.