Maybe there is a misunderstanding. The method you are quoting is supposed to tell the tableView which row to display at that indexPath. So, whenever the tableView asks for this method, it does so because there is no row at this indexPath yet.
The template code will generate a new cell or dequeue one:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
You can then access cell
to configure the content of each cell or add content to the contentView.
If you manipulate the formatting of a cell on a per row basis (e.g. the color of the cell.textLabel) you should do this in the following delegate method:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath