Skip to content

Instantly share code, notes, and snippets.

@bscofield
Created February 4, 2009 14:28
Show Gist options
  • Save bscofield/58123 to your computer and use it in GitHub Desktop.
Save bscofield/58123 to your computer and use it in GitHub Desktop.
- (void)viewDidLoad {
self.list = [self.data JSONValue];
[self.images removeAllObjects];
self.images = [NSMutableDictionary dictionaryWithCapacity:[self.list count]];
for (id rawItem in self.list) {
NSDictionary *item = (NSDictionary *)rawItem;
@try {
[self.images setObject:[UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: [item objectForKey:@"image_url"]]]] forKey:[item objectForKey:@"image_url"]];
}
@catch (NSException *exception) {}
}
[super viewDidLoad];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CustomCellIdentifier = @"CustomCellIdentifier";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier];
if (cell == nil) {
NSArray *nib = (NSArray *)[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
NSDictionary *item = (NSDictionary *)[list objectAtIndex:indexPath.row];
cell.description.text = [item objectForKey:@"description"];
cell.avatar.image = [images objectForKey:[item objectForKey:@"image_url"]];
return cell;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment