Using the Facebook iOS SDK, how can I get an NSArray
of all my friends and send them an invitation to my app? I am specifically looking for the graph path to ge
Use the function below to asynchronously fetch user's friends stored in an NSArray:
- (void)fetchFriends:(void(^)(NSArray *friends))callback
{
[FBRequestConnection startForMyFriendsWithCompletionHandler:^(FBRequestConnection *connection, id response, NSError *error) {
NSMutableArray *friends = [NSMutableArray new];
if (!error) {
[friends addObjectsFromArray:(NSArray*)[response data]];
}
callback(friends);
}];
}
In your code, you can use it as such:
[self fetchFriends:^(NSArray *friends) {
NSLog(@"%@", friends);
}];