Skip to content

Instantly share code, notes, and snippets.

@moflo
Created May 14, 2011 15:21
Show Gist options
  • Save moflo/972316 to your computer and use it in GitHub Desktop.
Save moflo/972316 to your computer and use it in GitHub Desktop.
Method for creating a UITableViewCell stuffed with LinkedIn user data
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
ToolAppImportContactCell *cell = (ToolAppImportContactCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Grab LinkedIn User Data
// LinkedInUser is a custom object container for name, LinkedInID and avatar URL
LinkedInUser *person = [self.list objectAtIndex:indexPath.row];
// Generate NSString to display in cell
cell.nameLabel.text = [NSString stringWithFormat:@"%@ %@",(person.name?person.name:@""),(person.name_last?person.name_last:@"")];
// Display the LinkedIn User's status (ie., location)
cell.statusLabel.text = person.user_status;
// Once an avatar URL is loaded, it is stuffed into the LinkedInUser object as a UIImage, check for this
if (person.uiimage) {
// If we have previously loaded a UIIimage, display it
cell.avatarView.image = person.uiimage;
}
else {
// If there is no UIImage it means we need to load the avatar URL, stuff a placeholder image instead
cell.avatarView.image = [UIImage imageNamed:@"User_Icon_LinkedIn.png"];
// Fire off thread to download image, asynchronously
[NSThread detachNewThreadSelector:@selector(asynchronouslyLoadPersonImage:) toTarget:self withObject:person];
}
cell.accessoryType = UITableViewCellAccessoryNone; // Default
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment