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 ...

Get Learning iPhone Programming 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.