Recently I have been working on some iPhone applications. I have strong opinions on the process of developing in the XCode environment, using Interface Builder, the poor development Mac tools and the general coding pain I have been going through, but that is a post for another day. What I wanted to focus on here is a problem I just resolved with the UITableViewController class.

For those not familiar with Mac’s Cocoa programming, a standard way of displaying lists of information is to use the ubiquitous UITableViewController class. It is a controller class provides support for displaying data in a table. It seems pretty straight forward, but alas, it has its pitfalls.

The UITableViewController class allows you to add items and (optionally) sections to the table. For example if you wanted to add the names of your friends, you could add them one at a time. You would then have a 0 based index of your friends. And if you wanted to group them (let’s say into male and female) you would have a 0 based index of gender types, each with a 0 based list of friend names.