ios - Loading Facebook data into a table view -


i stuck on proper way user's facebook friends , load table view (i use fbfriendpickerviewcontroller ugly , doesn't appear can fix that)

all want profile picture in cell imageview , name in cell textlabel, simple that.

doing nsurl/nsdata doesn't crop images, id rather use fbprofilepictureview please try use in solutions. thanks!

get data facebook

-(void)facebookopensession {      if (fbsession.activesession.isopen) {         [[fbrequest requestformyfriends] startwithcompletionhandler:^(fbrequestconnection *connection, id result, nserror *error) {              if (error) {                 // handle error             } else {                 self.facebookfriends = [nsarray arraywitharray:[result objectforkey:@"data"]];                 [[nsnotificationcenter defaultcenter] postnotificationname:@"facebookrequestformyfriends" object:self];             }         }];     } } 

configure data cell

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"cell" forindexpath:indexpath];      // configure cell...     nsdictionary<fbgraphuser> *friend = [self.facebookfriends objectatindex:indexpath.row];     cell.textlabel.text = friend.name;      nsurl *profilepictureurl = [nsurl urlwithstring:[nsstring stringwithformat:@"http://graph.facebook.com/%@/picture?type=normal", friend.id]];      nsdata *profilepicturedata = [nsdata datawithcontentsofurl:profilepictureurl];      cell.imageview.image = [uiimage imagewithdata:profilepicturedata];      return cell; } 

how people learn how make these things facebook sdk, spent 4 hours trying described above , feel missing something.

there several open source libraries make task of downloading image easy. favorite afnetworking, there's sdwebimage. using 1 of these categories, task becomes simple as:

[myimageview setimageurl:"http://test.com/test.jpg"]; 

even if don't want use these libraries, don't way you're attempting (i.e. [nsdata datawithcontentsofurl:profilepictureurl]). believe synchronous operation block ui. use code 1 of 2 links above, or make own uiimageview category.


Comments