title: Objective-C: Asynchronously populate UITableView - how to do this?
body: <p>I can't seem to find any info on this question, so I thought I'd ask the community.</p>
  
  <p>Basically, I have a UITableView and I want to show an activity indicator while its data is loading from my server.</p>
  
  <p>Here is some example code of what I'm trying to do (I'm using ASIHttpRequest).</p>
  
  <pre><code>    //self.listData = [[NSArray alloc] initWithObjects:@"Red", @"Green", @"Blue", @"Indigo", @"Violet", nil];   //this works
      NSString *urlStr=[[NSString alloc] initWithFormat:@"http://www.google.com"];   //some slow request
      NSURL *url=[NSURL URLWithString:urlStr];
  
      __block ASIHTTPRequest *request=[ASIHTTPRequest requestWithURL:url];
      [request setDelegate:self];
      [request setCompletionBlock:^{
          self.listData = [[NSArray alloc] initWithObjects:@"Red", @"Green", @"Blue", @"Indigo", @"Violet", nil];   //this doesn't work...
          [table reloadData];
  
      }];
      [request setFailedBlock:^{
  
      }];
      [request startAsynchronous];
  </code></pre>
  
  <p>The dummy request to google.com does nothing - it just creates a delay and in the response I hope to repopulate the table with some JSON response from my own website.</p>
  
  <p>But when I try to populate the table with the colours, nothing happens! I just get a blank table... If I uncomment the line above, it works fine, it's just on http responses things don't work for me.</p>
  
  <p>Any suggestions greatly appreciated.</p>
  
  <h2>Edit:</h2>
  
  <p>I did a <code>[self.tableView reloadData];</code> and now it works...</p>