2013-09-03 1 views
1

그래서 Facebook 친구의 UITableView이 있고 셀에는 이미지를 추가하고 싶습니다. 나는 다음과 같은 코드를하려고하면Objective-C UITableView 셀 이미지

는 :

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

모든 것이 잘 작동합니다. 그 이미지의 대상을 하드 코딩하는 것 그러나 나는 이런 식으로 뭔가를 할 때 있지만 :

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

이 링크 앞에 @ 기호를 가리키는 동안 '사용되지 않는 표현의 결과'라는 나에게 경고를 제공합니다.

왜 이런 생각입니까?

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

를하지만 나에게 경고 '형태는 NSString의 매개 변수에있는 UIImage를 전송 호환되지 않는 포인터 타입'을주고 :

나는 또한 시도했다.

답변

2

교체하려고 : (@"http://graph.facebook.com/%@/picture", thisFriend.friendID)이와 함께 : 당신은 그냥 문자열을 포맷하는 방법을 잊었처럼

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

보인다.

+0

그건 속임수 였어. 내 부분에 얼마나 당황 스럽습니까! 고마워요 Bek :) –

+1

그것은 우리 모두에게 일어난 일입니다! – Bek

+0

다음은 또 다른 빠른 질문입니다. 어떻게하면 이렇게 만들 수 있습니까? cell.imageView.image = [UIImage thisFriend.friendPhoto]; –

1

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

답장을 보내 주셔서 감사합니다. 그것은 또한 정확했다. –