Skip to content

Instantly share code, notes, and snippets.

@champierre
Created December 17, 2010 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save champierre/744625 to your computer and use it in GitHub Desktop.
Save champierre/744625 to your computer and use it in GitHub Desktop.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"SampleTable";
if (!tweetMessages) {
UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
cell.textLabel.text = @"loading...";
cell.textLabel.textColor = [UIColor grayColor];
return cell;
}
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = [tweetMessages objectAtIndex:[indexPath row]];
cell.textLabel.adjustsFontSizeToFitWidth = YES;
cell.textLabel.numberOfLines = 3;
cell.textLabel.font = [UIFont boldSystemFontOfSize:12];
cell.textLabel.textColor = [UIColor darkGrayColor];
if (dispatch_queue_create != NULL) {
cell.imageView.image = [UIImage imageNamed:@"blank.png"];
dispatch_async(image_queue, ^{
UIImage *icon = [self getImage:[tweetIconURLs objectAtIndex:[indexPath row]]];
dispatch_async(main_queue, ^{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.imageView.image = icon;
});
});
} else {
cell.imageView.image = [self getImage:[tweetIconURLs objectAtIndex:[indexPath row]]];
}
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment