bscofield (owner)

Revisions

gist: 58123 Download_button fork
public
Public Clone URL: git://gist.github.com/58123.git
Embed All Files: show embed
Objective-C #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- (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;
}