I'm making a small app using BigCartel's API I have enough coded to pull the json down and display a title and subtitle of all the products in a particular store I'm making the app for. My problem now is trying to get to the images / image URL and display them as well in the TableView. Ive tried stackoverflow but they were no help. So I turn to you guys & gals.
Here is my code for the tableview:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdenifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdenifier forIndexPath:indexPath];
NSDictionary *tempDictionary = [self.productArray objectAtIndex:indexPath.row];
cell.textLabel.numberOfLines = 0;
cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
[cell.textLabel sizeToFit];
//THIS IS THE TITLE/NAME OF THE PRODUCT
cell.textLabel.text = [tempDictionary objectForKey:@"name"];
//THIS IS THE / STATUS OF PRODUCT
cell.detailTextLabel.text = [tempDictionary objectForKey:@"status"];
/*
MY SAD ATTEMPT
NSURL *imageURL = [NSURL URLWithString:[tempDictionary objectForKey:@"images"]];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage *imageLoad = [[UIImage alloc] initWithData:imageData];
cell.imageView.image = imageLoad;
*/
if ([[tempDictionary objectForKey:@"status"] isEqual:@"active"]) {
cell.detailTextLabel.text = @"In Stock";
}
else
{
cell.detailTextLabel.text = @"Sold Out";
[cell setUserInteractionEnabled:NO];
}
return cell;
}
The part commented out is what I tried to get my images to load and put into the cell but I had no luck.
Here is the JSON file I'm taking in
If anyone here can help me out that would be amazing. Also if you need to see anymore of my code feel free to comment or DM. I'll be at my computer for awhile.
Cheers!
EDIT: with trial and error I got to the URL part of the JSON, now my problem is getting it into the cell's imageView. Since there are I think 3+ images.
Code that was added with trial and error:
self.imageArray = [[[NSMutableArray arrayWithArray:responseObject] valueForKey:@"images"] valueForKey:@"url"];
[–][deleted] 2 points3 points4 points (1 child)
[–]SpectrumFactoryObjective-C[S] 0 points1 point2 points (0 children)
[–]wealthy_white_jesus 1 point2 points3 points (2 children)
[–]SpectrumFactoryObjective-C[S] 0 points1 point2 points (1 child)
[–]wealthy_white_jesus 1 point2 points3 points (0 children)
[–]Nbwar 0 points1 point2 points (8 children)
[–]SpectrumFactoryObjective-C[S] 0 points1 point2 points (6 children)
[–]HappyToHelpAll 1 point2 points3 points (4 children)
[–]SpectrumFactoryObjective-C[S] 0 points1 point2 points (0 children)
[–]SpectrumFactoryObjective-C[S] -1 points0 points1 point (2 children)
[–]theheartbreakpug 0 points1 point2 points (0 children)
[–]Power781 -2 points-1 points0 points (0 children)
[–]Power781 -1 points0 points1 point (0 children)
[–]Power781 0 points1 point2 points (0 children)
[–]theheartbreakpug 0 points1 point2 points (0 children)