我想使用FBFriendsPickerViewController提供有限的朋友列表(例如,由特定的FQL生成)。文档提示可以使用FBCacheDescriptor预取好友列表,但后者的文档很差。我没有在SDK示例中找到任何示例。
答案 0 :(得分:3)
据我了解,FBCacheDescriptor是预取您需要的数据,以提高表视图的响应能力。例如,如果要缓存好友选择器列表,可以执行类似......
的操作- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions {
if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
[FBSession sessionOpen];
FBCacheDescriptor *cacheDescriptor = [FBFriendPickerViewController cacheDescriptor];
[cacheDescriptor prefetchAndCacheForSession:FBSession.activeSession];
}
return YES;
}
Facebook提供的Scrumptious演示应用程序就是一个很好的例子。
你可以使用新的API执行FQL,但是就像我说的那样,在任何地方都没有记录。以下是使用新SDK运行FQL的方法......
- (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];
}
答案 1 :(得分:2)
- (BOOL)friendPickerViewController:(FBFriendPickerViewController *)friendPicker shouldIncludeUser:(id<FBGraphUser>)user