title: UITableView and Async loading with NSURLconnection
body: <p>I'm having an issue which to me looks like my JSON URL request is completing after I load my UITableView. I attempted to reload the UITableview but that either isn't working properly or didn't do the trick as some of the other questions suggested. This viewcontroller is being coming off an AppDelegate. Would appreciate a steer if anyone sees something I'm not doing right.</p>
  
  <pre><code>#import "AppDelegate.h"
  #import "ViewController.h"
  #import "DetailViewController.h"
  #import "JSON.h"
  
  @implementation ViewController
  @synthesize states,responseData,datasource,appDelegate,_tableView;
  @synthesize allTeams;
  
  #pragma mark - View lifecycle
  
  - (void)viewDidLoad
  {
  
      [self setupArray];
      [super viewDidLoad];
  
      // inside all teams
      NSLog(@"in VIEW allTeams count, %u",[allTeams count]);
  // Do any additional setup after loading the view, typically from a nib.
  }
  
  -(void)setupArray{
      responseData = [NSMutableData data];
  
      NSLog(@"Want to get teams for via the url");
      NSURLRequest *request = [NSURLRequest requestWithURL:
                           [NSURL     URLWithString:@"http://skyrink.secretagents.us/service/"]];
  
      [[NSURLConnection alloc]  initWithRequest:request delegate:self];
  
      }
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
      //#warning Incomplete method implementation.
      // Return the number of rows in the section.
      NSLog(@"datasource number of rows in section count, %u",[datasource count]);
      NSLog(@"allTeams number of rows in section count, %u",[allTeams count]);
      return [allTeams count];
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"Cell";
      UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      if (cell == nil) {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
      }
      // Configure the cell...
  
      //---------- CELL BACKGROUND IMAGE -----------------------------
      UIImageView *imageView = [[UIImageView alloc] initWithFrame:cell.frame];
      UIImage *image = [UIImage imageNamed:@"LightGrey.png"];
      imageView.image = image;
      cell.backgroundView = imageView;
      [[cell textLabel] setBackgroundColor:[UIColor clearColor]];
      [[cell detailTextLabel] setBackgroundColor:[UIColor clearColor]];
  
      //cell.textLabel.text = [datasource objectAtIndex:indexPath.row];
  
      //Arrow 
      cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  
      return cell;
  }
  
  -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
       NSLog(@"inside detail view");
      DetailViewController *detail = [self.storyboard     instantiateViewControllerWithIdentifier:@"detail"];
      detail.state = [allTeams objectAtIndex:indexPath.row];
      detail.capital = [states objectForKey:detail.state];
      [self.navigationController pushViewController:detail animated:YES];
  
  }
  
  - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
          NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
      NSMutableArray *allTeams = [(NSDictionary *)[responseString JSONValue] objectForKey:@"TeamList"];
  
      NSLog(@"allTeams count, %u",[allTeams count]);
      NSLog(@"Start reload");
          //[self._tableView reloadData];
          NSLog(@"Stop reload");
      }
  
  
  
  
  @end
  </code></pre>