Skip to content

Instantly share code, notes, and snippets.

@tlkahn
Created December 18, 2015 05:26
Show Gist options
  • Save tlkahn/dba464882e26baf97242 to your computer and use it in GitHub Desktop.
Save tlkahn/dba464882e26baf97242 to your computer and use it in GitHub Desktop.
uitableview data source
#pragma mark UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.statuses count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"STTwitterTVCellIdentifier"];
if(cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"STTwitterTVCellIdentifier"];
}
NSDictionary *status = [self.statuses objectAtIndex:indexPath.row];
NSString *text = [status valueForKey:@"text"];
NSString *screenName = [status valueForKeyPath:@"user.screen_name"];
NSString *dateString = [status valueForKey:@"created_at"];
cell.textLabel.text = text;
cell.detailTextLabel.text = [NSString stringWithFormat:@"@%@ | %@", screenName, dateString];
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment