A cellForRowAtIndexPath example code (contains implementation).When any tableViewCell object moves out of the screen, it is automatically collected by the tableView object for reuse. dequeueReusableCellWithIdentifier method tries to get a cell that matches the identifier from the pool of reused cell. To achieve maximum performance, you should always reuse tableViewCell. Following fragment shows an cellForRowAtIndexPath example code.Nearly all tableView:cellForRowAtIndexPath method takes this standard form.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static
NSString *SimpleTableIdentifier = @
"SimpleTableIdentifier"
;
deueueReusableCellWithIdentifier method tries to get a cell
// that matches the identifier from the pool of reused cell.
// To achieve maximum performance, you should always reuse tableViewCell.
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
if
(cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewStyleDefault] reuseIdentifier:SimpleTableIdentifier] autorelease];
}
NSInteger row = [indexPath row];
cell.textLabel.text = [listData objectAtIndex:row];
return
cell;
}