Search code examples
iphonecelltableviewcontrollers

UITableView row cell controllers


My first post ever (so please be patient).

I am building a group UITableView. Each section is defined and stored in an object called TableViewSectionClass.

The rows is different section will use different sub-classes of UITableCell to make the rows in various sections display differently. I.e. One line in one section, two in another, two with an image in another.

How can I store the "UITableCell class type needed to create my particular kind of row cell" in my TableViewSectionClass?


Solution

  • You can store it in a property/ivar of type Class; you retrieve the appropriate class object using the class class method, of course, something like tableViewSectionClass.tableCellClass = [MyUITableCellClass class].

    You can use this class object just as you would a bare class name when calling class methods such as alloc: [[self.tableCellClass alloc] initWithStyle:... reuseIdentifier:[self.tableCellClass description]].