title: Method returning value from asynchronous block with FacebookSDK
body: <p>What I am trying to do is a Facebook wrapper for the Facebook iOS SDK. Basically the idea is that my ViewController should do nothing but showing ex. my friends that will be acquired with a simple call like</p>
  
  <pre><code>self.friends = [FacebookWrapper myFriends];
  [self.tableView reloadData];
  </code></pre>
  
  <p>My wrapper myFriends method should look like this</p>
  
  <pre><code>+ (NSArray *)myFriends
  {
     __block NSArray *friends = nil;
     [FBSession openActiveSessionWithReadPermissions:nil allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
      if(FB_ISSESSIONOPENWITHSTATE(status)) {
      [FBRequestConnection startForMyFriendsWithCompletionHandler:^(FBRequestConnection *connection, id data, NSError *error) {
         CFRunLoopStop(CFRunLoopGetCurrent());
          if(error) {
              return;
          }
          NSArray *friendsData = (NSArray *)[data data];
          NSMutableArray *fbFriends = [NSMutableArray array];
          for(id friendData in friendsData) {
              Friend *friend = [Friend friendWithDictionary:friendData];
              fbFriends addObject:friend];
          }
          friends = [NSArray arrayWithArray:fbFriends];
      }];
      CFRunLoopRun();
      }
    }];
    return friends;
  }
  </code></pre>
  
  <p>The issue is that the openActiveSessionWithReadPermissions and startForMyFriendsWithCompletionHandler are asynchronous blocks so the method returns before the blocks complete their task.</p>
  
  <p>Any help would be much appreciated.</p>