0

I am creating Iphone app to get image from the rest api and show the image in table cell. I used the following code. But it does not work. Can anyone help me to do this.

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
[cell.textLabel setLineBreakMode:NSLineBreakByWordWrapping];
[cell.textLabel sizeToFit];

if(cell == nil)
{
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.imageView.image = [UIImage imageNamed:"http://122.182.130.142:9090/abc/abc/abc.jpg"];
cell.textLabel.text = [NSString stringWithFormat:[message objectAtIndex:0], indexPath.row];
return cell;
}

Thanks in advance.

Balaji Kondalrayal
  • 1,743
  • 3
  • 19
  • 38
  • First load imageData of this link "http://122.182.130.142:9090/abc/abc/abc.jpg" and convert that into image, Then set as image – Yogendra Jul 03 '14 at 07:02

1 Answers1

1

Try this line.

UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:MyURL]]];
Snowmanzzz
  • 240
  • 5
  • 15