Graphics Programs Reference
In-Depth Information
reuseIdentifier:@"UITableViewCell"];
// Check for a reusable cell first, use that if it exists
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
// If there is no reusable cell of this type, create a new one
if (!cell) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"UITableViewCell"];
}
BNRItem *p = [[[BNRItemStore sharedStore] allItems]
objectAtIndex:[indexPath row]];
[[cell textLabel] setText:[p description]];
return cell;
}
(If you have a table view that uses multiple styles of the same type of cell, you can suffix
the reuse identifier with the name of that style, e.g. UITableViewCell-Default .)
Reusing cells means that you only have to create a handful of cells, which puts fewer de-
mands on memory. Your application's users (and their devices) will thank you. Build and
run the application. The behavior of the application should remain the same.
Search WWH ::




Custom Search