Chapter 2. Interface Builder: Xcode's GUI for GUIs

One of the most time-consuming steps in writing an application can be designing the UI. The iPhone has a UI that's unmistakable from any other mobile deviceā€”a feature-rich, high-resolution form factor designed to accommodate navigation without a stylus (it's fat finger-friendly). Old school hackers who have written UIs by hand will tell you that they require a lot of code and more time than a developer wants to spend on them. The good news is that Apple went to great lengths to make it simple for SDK developers to implement a standard set of UIs. The iPhone SDK includes a utility named Interface Builder, which gives the designer a WYSIWYG drag-and-drop environment for creating and editing windows, creating views, and placing controls on the screen with little effort. The user can store the screen layout as a template file, which your application can read and synthesize as an object in your application. This allows you to create a user interface in minutes and make future changes with little or no code changes. Desktop developers might remember this approach from resource forks of the past.

The Interface Builder application can be found in the /Developer applications folder on your desktop machine. If you followed our advice in Chapter 1, you've already dragged this folder onto your dock, and you can launch it by opening the dock stack and selecting the Interface Builder application. If you haven't heeded our sage advice, you'll need to navigate to your hard drive in the Finder and launch Interface Builder from the /Developer/Applications folder.

While using Interface Builder doesn't preclude you from creating your own UI objects in Objective-C, many developers like to forego Interface Builder completely and define all UI components within their code. You'll learn how to do this at the end of the chapter.

NOTE

 

Synthesizing is the term Apple uses to describe the dynamic creation of linkage between a variable and the object it is connected with. When a class synthesizes an object from an Interface Builder template, the object is assigned to a variable within your class. View controllers, windows, and other types of Interface Builder objects can all be synthesized, allowing you to access them as variables without your application directly creating them.