title: reachability best practice
body: <p>My app pulls a json data feed , I have just added the reachability check in to the applicationDidBecomeActive in the app delegate . If the network is contactable then the viewcontroller is loaded. From the view controller the parser class gets called which populates a UITableview. 
  If the network is non-contactable it displays an alert. If the user presses the home button activates the wireless or cellular data and then returns to the app the viewcontroller gets loaded. Whilst this works the solution isn't particularly elegant as each time the user returns to the app after placing in the background the viewcontroller calls are run through again. I wonder if there any better alternatives?</p>
  
  <p>AppDelegate.m</p>
  
  <pre><code>  - (void)applicationDidBecomeActive:(UIApplication *)application {
  
  // Check for network connectivity
  
  reachability = [Reachability reachabilityForInternetConnection];
  [reachability startNotifier];
  
  NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];
  
  if(remoteHostStatus == NotReachable) {
      UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Connection Error" message:@"App cannot connect to the internet" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
      [alert show];
      [alert release];
      self.internetActive = NO;
  }
  
  
  else {
  
      NSLog(@"internet available");
      self.internetActive = YES;
  
  }
  
  
  // if internet available call viewcontroller;
  
  if (self.internetActive) {
      navController.viewControllers = [NSArray arrayWithObject:viewController];
      [window addSubview:navController.view];
      [window makeKeyAndVisible];
  }
  else {
      //error pic background display
  }
  </code></pre>
  
  <p>And then the viewcontroller.m</p>
  
  <pre><code>  - (void)viewDidLoad {
  
  UIApplication* app = [UIApplication sharedApplication];
  app.networkActivityIndicatorVisible = YES; 
  [loadingActivityIndicator startAnimating];
  
  Infoparser *cparser = [[FCO_parser alloc] init];
  [cparser queryclistwithViewCont:self];
  [cparser release];
  
  [super viewDidLoad];
  </code></pre>
  
  <p>}</p>