title: Waiting for a block to finish
body: <p>I have a UITableView and I'm attempting to get the number of rows. However, I'm having trouble using blocks. In the code below I'd just like to return count, but as I now understand blocks are asynchronous. I've looked around trying to find a solution but none of them worked. One solution I tried was this: <a href="https://stackoverflow.com/questions/4326350/how-do-i-wait-for-an-asynchronously-dispatched-block-to-finish">How do I wait for an asynchronously dispatched block to finish?</a> but when I clicked on the button to go to the view with the table, it just froze when the button was clicked. I tried some others, but they also did not work.</p>
  
  <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
    GlobalVars *globals = [GlobalVars sharedInstance];
  
    __block int count = 0;
    GKLocalPlayer *localPlayer = [[GameCenterHelper sharedInstance] getLocalPlayer];
    [[GameCenterHelper sharedInstance] getMatches:^(NSArray *matches) {
      NSLog(@"Matches: %@", matches);
      for (GKTurnBasedMatch *match in matches) {
        for (GKTurnBasedParticipant *participant in match.participants) {
          if ([participant.playerID isEqualToString:localPlayer.playerID]) {
            if (participant.status == GKTurnBasedParticipantStatusInvited) {
              [globals.matchesReceived addObject:match];
              count++;
              NSLog(@"INVITED");
            }
          }
        }
      }
    }];
  
    return count;
  }
  </code></pre>
  
  <p>Could someone help me properly get <code>count</code> returned? </p>