For a project I’m doing at work I had to create a table with several sections. Each section had several entries on which you pick only one (sort a like radio buttons). There are quite some tutorials on the interwebz demonstrating on how to create custom table items. Most of them showing tons and tons of customized stuff but really forget to get down to the basic stuff; so that’s where this tutorial comes in.
Lets say we have an interface called FlavouredIcecreamInterface which derives from TTTableViewController from the three20 library. We want to give our users the ability to select several flavors of ice cream and show them they have selected one of the items by showing a check mark on the accessory part of the cell.
@interface FlavouredIcecreamInterface : TTTableViewController { }
It is possible to set a check mark on cell of an accessory without creating custom classes, but because I want to show you how to create custom cells we’ll override the appropriate classes. Before we get in to any code it’s worth to mention that Three20 makes a fair distinction between Table Cells and Table Items.
- a Table Item is the data in your table
- a Table Cell is the representation of your data.
So Table Items = Data and Table cells = visual aspect. Hope that’s clear enough.
So what exactly is it we need? You know we need an Item class and a Cell class, and we need to somehow tell Three20 to use our custom Cell class when it encounters an Item class. This is where our custom Data Source comes in. The data source will simply hold our Item class instances and tells Three20 it needs to load our custom cell when it encounters our custom-made item class instances. All this might seem confusing but it will all get clear to you after the break

