Reputation: 2202
I am having a performance issue using the Facebook Graph API to pull a user's friends list. My issue is not in retrieving the list, but having to loop through the list once it is retrieved to get the user's picture.
The "me/friends" api call only returns the userId and userName. I then have to take each persons userID and make a call to get their picture. This slows down my UITableView of friends quite a bit.
Does anyone have a better solution to load all of the pictures?
Upvotes: 1
Views: 346
Reputation: 2492
To get their photo, you can construct it with a common URL (this is unique for pictures only). You are limited to the small one, though. So for the big ones, you need to use FQL to do a structured query. But that is a good option, and would work fine. FQL is a little awkward syntactically. You can test it in graph api explorer before popping into Xcode.
The options:
The picture url can be constructed as:
NSString *url = [[NSString alloc] initWithFormat:@"https://graph.facebook.com/%@/picture",objectID];
FQL query (this is a common one)
SELECT uid, name, pic_square FROM user WHERE uid = me() OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
But honestly, why do that when you can use the graph to get friend uids and construct the picture on the fly- except, of course, if you want a larger picture.
Upvotes: 0
Reputation: 22726
I guess, the problem should be because you must be loading all the images at once and that will block UI until all the images are downloaded for visible table cells images. That can be resolved by implementing Lazy Loading
. That is sample provide by APPLE itself so you can check code and use it as per your requirement.
Let me know if you stuck any where.
Hope this helps.
Upvotes: 4
Reputation: 1304
as far as i know, you have to do your stuff as u did. you have to use to GRAPH API to retrieve user's friend's photo.
First use the FriendList API to get the friend list, then get your friend's photo using Photo API.
I assume, you have done this way. One thing may be you can try is using AsynchronousImageView. Use AsynchronousImageView in your tableView to load the images asynchronously, so that it will not get stucked when loading the table view.
Upvotes: 2