title: How to request JSON data in the viewDidAppear method or viewDidLoad?
body: <p>If I call the <code>[self requestData];</code> from viewDidLoad my table populates itself with data just fine. If I move <code>[self requestData];</code> to the viewDidAppear method the table remains empty. </p>
  
  <p>Also, I'm not entirely sure if     <code>[self.mainTableView reloadData];</code> is working. I'm trying to move the data request and handling to the viewDidAppear method because I saw that pattern in a code example and thought it might speed up my app launch somewhat. At the moment there's quite a lag from the app launch Default.png to the rootViewController.</p>
  
  <p>thanks for any help with this.</p>
  
  <pre><code>-(void)viewDidAppear:(BOOL)animated
  {
  
      [self requestData];
  }
  
  
  
  -(void)requestData {
  
      [HUD showUIBlockingIndicatorWithText:@"Fetching JSON"];
  
      NSError *requestError = nil;
  
  
      NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL
                                                            URLWithString:kURL]];
  
      NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&amp;requestError];
  
      NSError *jsonParsingError = nil;
  
      if (requestError)
      {
          NSLog(@"sync. request failed with error: %@", requestError);
      }
      else
      {
          // handle data
          publicData =  [NSJSONSerialization JSONObjectWithData:response
                                                                      options:0
                                                                        error:&amp;jsonParsingError];
          publicDataArray = [publicData objectForKey:@"data"];
  
      }
  
      /*
       for(publicDataDict in publicDataArray) {
       NSLog(@"data output is %@",[publicDataDict objectForKey:@"title"]);
  
       }
       */
      [self.mainTableView reloadData];
  
          NSLog(@"reload table cat id %@", categoryString);
  
      [HUD hideUIBlockingIndicator];
  }
  </code></pre>