我正在尝试按照Facebook 开发人员网站上针对 iOS 版 FacebookSDK 的教程的指示运行 Facebook 多查询,以下是我在 iOS 应用程序中的代码:
-(BOOL) FBGetFriendList
{
if (FBSession.activeSession.isOpen)
{
// Multi-query to fetch the active user's friends
// Initial query is stored in reference named "friends"
// Second query picks up the "uid2" info from the first query
// and gets the friend details.
NSString *query =
@"{"
@"'friends':'SELECT uid2 FROM friend WHERE uid1 = me()',"
@"'friendinfo':'SELECT uid, name, pic_square FROM user WHERE is_app_user = 1 AND uid IN (SELECT uid2 FROM #friends)',"
@"}";
// Setup the query parameter
NSDictionary *queryParam = [NSDictionary dictionaryWithObjectsAndKeys:query, @"q", nil];
// Make the API request that uses FQL
[FBRequestConnection startWithGraphPath:@"/fql"
parameters:queryParam
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *_connection, id _result, NSError *_error) {
// check for errors here
if (_error)
{
NSLog(@"FacebookSDKPlugin > FBGetFriendList() > request error!");
}
else
{
@synchronized(friendList)
{
if (friendList == nil)
{
friendList = [[NSMutableArray alloc] init];
}
else
{
[friendList removeAllObjects];
}
NSArray *facebookData = [(NSDictionary *)_result objectForKey:@"data"];
int count = facebookData.count;
for (int i = 0; i < count; ++i)
{
NSDictionary<FBGraphUser> *tempObject = [facebookData objectAtIndex:i];
FacebookFriend *tempFriend = [[FacebookFriend alloc] initWithID:[tempObject.id copy] name:[tempObject.name copy]];
[friendList addObject:tempFriend];
}
}
}
}];
return YES;
}
return NO;
}
但是,在编译过程中会出现警告:
Class method '+startWithGraphPath:parameters:HTTPMethod:completionHandler:' not found (return type defaults to 'id')
我忽略了这个错误并在我的 iPad2 上编译,它因这个错误而崩溃:
2012-09-03 11:53:13.377 +[FBRequestConnection startWithGraphPath:parameters:HTTPMethod:completionHandler:]: unrecognized selector sent to class 0xa05350
2012-09-03 11:53:13.379 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[FBRequestConnection startWithGraphPath:parameters:HTTPMethod:completionHandler:]: unrecognized selector sent to class 0xa05350'
我已经包含了“FBRequest.h”和“Facebook.h”,我可以在“FBRequest.h”中看到方法。但是我不明白为什么编译器找不到该函数。有谁知道如何解决这个问题?