Yaser Sleiman
Yaser Sleiman

Reputation: 95

Objective-C UITableView cell image

So I have a UITableView of Facebook Friends and for a cell I want to add the image to it.

When I try the following code:

cell.imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:
[NSURL URLWithString: (@"http://graph.facebook.com/shaverm/picture")]]];

Everything works fine. Although that's hardcoding the image destination but when I do something like this:

cell.imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:
[NSURL URLWithString: (@"http://graph.facebook.com/%@/picture", thisFriend.friendID)]]];

It gives me a warning stating 'Expression result unused' whilst pointing at the @ symbol before the link.

Any ideas why this is happening?

I also tried:

cell.imageView.image = [UIImage imageNamed:thisFriend.friendPhoto];

But that's giving me a 'Incompatible pointer types sending UIImage to parameter of type NSString' warning.

Upvotes: 1

Views: 1069

Answers (2)

Bek
Bek

Reputation: 2226

replace: (@"http://graph.facebook.com/%@/picture", thisFriend.friendID) with this:

[NSString stringWithFormat:@"http://graph.facebook.com/%@/picture", thisFriend.friendID];

Looks like you just forgot the method for formatting a string.

Upvotes: 2

Vik
Vik

Reputation: 1927

try

cell.imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:
    [NSURL URLWithString:[NSString stringWithFormat:@"http://graph.facebook.com/%@/picture", thisFriend.friendID]]]];

Upvotes: 1

Related Questions