Skip to content

Instantly share code, notes, and snippets.

@vincent178
Created December 10, 2013 13:33
Show Gist options
  • Save vincent178/7890625 to your computer and use it in GitHub Desktop.
Save vincent178/7890625 to your computer and use it in GitHub Desktop.
Separate Out Data Source
@implementation ArrayDataSource
- (id)itemAtIndexPath:(NSIndexPath*)indexPath {
return items[(NSUInteger)indexPath.row];
}
- (NSInteger)tableView:(UITableView*)tableView
numberOfRowsInSection:(NSInteger)section {
return items.count;
}
- (UITableViewCell*)tableView:(UITableView*)tableView
cellForRowAtIndexPath:(NSIndexPath*)indexPath {
id cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier
forIndexPath:indexPath];
id item = [self itemAtIndexPath:indexPath];
configureCellBlock(cell,item);
return cell;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment