UITableViewCells and UITableViewDataSource
A UITableViewDataSource must implement:
tableView:numberOfRowsInSection:
tableView:cellForRowAtIndexPath:
Each row in a UITableView is a UITableViewCell. Each UITableViewCell has a contentView, which holds the content for the cell.
Each TableViewCell has a UITableViewCellStyle which determines the composition of subviews within the contentView.
To map cells to items:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCell"]; Record *record = [[itemStore allItems] objectAtIndex:[indexPath row]]; [[cell textLabel] setText:[p description]];
return cell; } - (NSInteger)tableView(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [[itemStore allItems] count]; }
itemStore here is an object that holds an NSMutableArray, allItems. This data source will typically exist on the UITableViewController backing the UITableView.










