title: How to check network status in iphone app?
body: <p>I have setup some methods to check network status in my app.</p>
  
  <p>In my <code>viewDidLoad</code> method I call <code>initNetworkCheck</code>:</p>
  
  <pre><code>[self initNetworkCheck];
  [super viewDidLoad];
  if(internetActive == NO){     
      compose.enabled = NO;
  }
  </code></pre>
  
  <p>So I want to check on startup if the hardware has internet connection. The problem is it gives me always NO but internetActive is actually YES when I log it.</p>
  
  <pre><code>//[[[[[[network check methods
  -(void)checkNetworkStatus:(NSNotification *)notice{
      NetworkStatus internetStatus = [internetReachable currentReachabilityStatus];
      switch (internetStatus) {
          case NotReachable:{
              self.internetActive = NO; 
              break;
          }
          case ReachableViaWiFi:{
              self.internetActive = YES;
              break;
          }
          case ReachableViaWWAN:{
              self.internetActive = YES;
              break;
          }
      }
      NetworkStatus hostStatus = [hostReachable currentReachabilityStatus];
      switch (hostStatus){
          case NotReachable:{
              self.hostActive = NO;
              break;
          }
          case ReachableViaWiFi:{
              self.hostActive = YES;
              break;
          }
          case ReachableViaWWAN:{
              self.hostActive = YES;
              break;
          }
      }
  
  }
  -(void)initNetworkCheck{
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];
  
      internetReachable = [[Reachability reachabilityForInternetConnection] retain];
      [internetReachable startNotifier];
  
      hostReachable = [[Reachability reachabilityWithHostName:@"www.google.com"] retain];
      [hostReachable startNotifier];
  }
  //]]]]]]
  </code></pre>
  
  <p>Any ideas?</p>