Why does this TableView code work?
- by nevan
I made a typo when creating a UITableViewCell with this code:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [self.tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSLog(@"Creating cell");
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewStylePlain
reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = @"Hello";
return cell;
}
The typo is in using UITableViewStylePlain instead of UITableViewCellStyleDefault. The code worked fine, creating new cells. Why?