Created
February 4, 2009 14:28
-
-
Save bscofield/58123 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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