0

I have one API.It is having 4 images and 4 descriptions and 4 names. So My question is when we parse and run the app these things should be displayed at a time.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{

    DetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];

    if (indexPath.section==0)
    {
        cell.discriptionLabel.text = [arrDiscription  objectAtIndex:indexPath.row];
    }
    else if (indexPath.section==1)
    {
        cell.displayLabel.text = [arrDisplayName  objectAtIndex:indexPath.row];
    }
    else
    {
        [cell.imgObj setImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"image"]]]];
    }
    return cell;
}


NSArray *arrActivity1=[dictionray valueForKey:@"products"];

for (NSDictionary *dicObj in arrActivity1)
{
    NSString *strDiscription=[dicObj valueForKey:@"description"];
    [arrDiscription addObject:strDiscription];
    NSLog(@"discriptions are %@",arrDiscription);

    NSString *strDisplyName=[dicObj valueForKey:@"display_name"];
    [arrDisplayName addObject:strDisplyName];
    NSLog(@"displaynames are %@",arrDisplayName);
}

This is my parsing, but I am unable to display the images on the tableview. Please anyone help me.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
suresh
  • 1

1 Answers1

0

SDWebImage

Is what you're looking for.

Use it in your cellForRowAtIndexPath delegate method like this:

[cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"image"] placeholderImage:[UIImage imageNamed:@"sampleimage.png"]];
Luis Mejías
  • 301
  • 2
  • 10