Dequeuing Cells

Your data source responds to cell requests by building cells from code, or it can load its cells from Interface Builder (IB) sources. Here’s a minimal data source method that returns a cell at the requested index path and labels it with text derived from its data model:

- (UITableViewCell *)tableView:(UITableView *)aTableView     cellForRowAtIndexPath:(NSIndexPath *)indexPath {     UITableViewCell *cell = [self.tableView         dequeueReusableCellWithIdentifier:@"cell"         forIndexPath:indexPath];     cell.textLabel.text =         [dataModel objectAtIndexPath:indexPath].text;     return cell; }

If you’re an established iOS developer, you’ll appreciate this: You no longer need to check to see ...

Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.