Appendix F. Working with Interface Builder

In this appendix, we use Interface Builder to build a couple of iPhone applications. The techniques you learn from building these applications should prove to be useful in building similar iPhone applications.

National Debt Clock Application

In this section, we develop the National Debt Clock application. The application's UI is developed using Interface Builder. A screenshot of the completed product is shown in Figure F.1.

Creating the project

Launch XCode. Click on File > New Project. Click on the Application category under iPhone OS. Choose Window-based Application and click on Choose.

Name the project NationalDebt and click Save.

Creating the view controller class

Right-click on the Classes group and select Add > New File as shown in Figure F.2.

Select UIViewController subclass under the Cocoa Touch Class as shown in Figure F.3 and click on Next.

Name the file DebtViewController.m, make sure that the check box for generating the header file is checked, and click Finish.

As the screenshot of the application in Figure F.1 shows, there are four main UI elements:

  • A label. An instance of UILabel is used to show the text National Debt Clock. This is a static text that our application need not change. No code in our controller needs to know about this UI element.

    A screenshot of the National Debt Clock application.

    Figure F.1. A screenshot of the National Debt Clock application.

    Figure F.2. Adding a new class. ...

Get iPhone SDK 3 Programming: Advanced Mobile Development for Apple iPhone and iPod touch 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.