Reputation: 58
I am trying to run a Facebook multi-query as instructed by the tutorial on the Facebook developer's site for FacebookSDK for iOS, below is the code I have in my iOS app:
-(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;
}
However, during compilation there is a warning:
Class method '+startWithGraphPath:parameters:HTTPMethod:completionHandler:' not found (return type defaults to 'id')
I ignored the error and compiled on my iPad2, which crashed with this error:
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'
I have included "FBRequest.h", and "Facebook.h", and I can see the method in "FBRequest.h". However I don't understand why the compiler cannot find the function. Does anybody have any idea how to solve this issue?
Upvotes: 0
Views: 1532
Reputation: 58
Opps I realized I have been using the older version of FacebookSDK, which explains why the code doesn't work as stated in the official tutorial. Updating to the latest version of the SDK (Version 3.0.8) fixed this issue!
Upvotes: 1