Reputation: 493
I would like to present a limited list of friends (e.g. generated by a specific FQL) using FBFriendsPickerViewController. The documentation hints that the friends list can be pre-fetched using FBCacheDescriptor, but the documentation of the latter is poor. I didn't find any example in the SDK samples.
Upvotes: 2
Views: 2970
Reputation: 136
- (BOOL)friendPickerViewController:(FBFriendPickerViewController *)friendPicker shouldIncludeUser:(id<FBGraphUser>)user
Upvotes: 2
Reputation: 63
As far as I understand, FBCacheDescriptor is to prefetch the data you need, to improve the responsiveness of the table views. For example, if you want to cache the friend picker list, you can do something like...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions {
if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
[FBSession sessionOpen];
FBCacheDescriptor *cacheDescriptor = [FBFriendPickerViewController cacheDescriptor];
[cacheDescriptor prefetchAndCacheForSession:FBSession.activeSession];
}
return YES;
}
There is a good example on Scrumptious demo app provided by Facebook.
You can execute FQL using the new API, but like I said tying that with the Cache is not documented anywhere. Here's how you can run FQL using the new SDK...
- (void)getFacebookFriends {
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Your FQL Query goes here", @"query",
nil];
FBRequestConnection *connection = [FBRequestConnection new];
FBRequestHandler handler =
^(FBRequestConnection *connection, id result, NSError *error) {
........
//Process the result or the error
NSLog(@"%@", result);
};
FBRequest *request = [[FBRequest alloc] initWithSession:FBSession.activeSession
restMethod:@"fql.query"
parameters:[params mutableCopy]
HTTPMethod:HTTP_GET];
[connection addRequest:request completionHandler:handler];
[self.requestConnection cancel];
self.requestConnection = connection;
[connection start];
}
Upvotes: 3