Cover by Alasdair Allan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Chapter 5. Table-View-Based Applications

The UITableView and associated classes are perhaps the most commonly used classes when building UIs for your iPhone or iPod touch applications. Due to the nature of the applications, you can use these classes to solve a large cross section of problems, and as a result they appear almost everywhere. In this chapter, we’re going to dive fairly deeply into the table view classes, and by the end of it you’ll be able to produce UITableView-based applications on your own. We’ll also discuss some features of Xcode and Interface Builder as we go along.

We’re going to write a simple guidebook application. We’ll start by displaying a list of cities in a table (using the UITableView class). Then we’ll add the ability to click on the city name inside each table cell (each cell is a UITableViewCell object), which will take you to a page describing the city. Later in the chapter I’ll show you how to add and delete cities to and from the guidebook. By the end of the chapter, we will have a working guidebook application. However, before we get to write some new code, we’re going to do some helpful refactoring of the template code generated by Xcode.

Open Xcode and choose “Create a new Xcode project” in the startup window, and then choose the View-based Application template from the New Project pop-up window, the sample template we used for our Hello World application in Chapter 3. When prompted, name your new project CityGuide.

Simplifying the Template Classes ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required