title: iOS/iPhone Reachability - How to only check when internet is lost/not reachable using Reachability.m/.h
body: <p>Currently i am using the class by apple reachability.m/.h and it works, except it notifies me for any change, where as i would like to only notify the user if the network is not reachable. Currently if i have a internet connection and then loose the network it tells me. However when you reconnect to the network it also tells me, which i do not want. I want it to only tell me when there is a loss/no network.</p>
  
  <p>I believe it has something to do with the call:</p>
  
  <pre><code>- (void)viewWillAppear:(BOOL)animated
  {
      // check for internet connection
      [[NSNotificationCenter defaultCenter]
            addObserver:self
               selector:@selector(checkNetworkStatus:)
                   name:kReachabilityChangedNotification
                 object:nil];
  
      internetReachable = [[Reachability
                           reachabilityForInternetConnection] retain];
      [internetReachable startNotifier];
  
      // check if a pathway to a random host exists
      hostReachable = [[Reachability reachabilityWithHostName:
                       @"www.google.ca"] retain];
      [hostReachable startNotifier];
  
      // now patiently wait for the notification
  }
  </code></pre>
  
  <p>when calling <code>-[NSNotificationCenter addObserver:selector:name:object:]</code>, does the name have any other function then being literally a name? this is my first time using NSNotificationCenter so i am not well versed in this matter. </p>
  
  <p>EDIT:</p>
  
  <p>Here is my checkNetworkStatus function: (The problem is i am getting "NotReachable" as the network connection is coming back and NSAlert goes off multiple times)</p>
  
  <pre><code>- (void) checkNetworkStatus:(NSNotification *)notice
  {
          // called after network status changes
  NetworkStatus internetStatus = [internetReachable currentReachabilityStatus];
  switch (internetStatus)
  
  {
      case NotReachable:
      {
          UIAlertView * alert  = [[UIAlertView alloc] initWithTitle:@"Network Failed" message:@"Please check your connection and try again." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil ];
          [alert show];
          NSLog(@"The internet is down.");
  
          break;
  
      }
      case ReachableViaWiFi:
      {               
          NSLog(@"The internet is working via WIFI.");
  
          break;
  
      }
      case ReachableViaWWAN:
      {
          NSLog(@"The internet is working via WWAN.");
  
          break;
  
      }
  }
  
  NetworkStatus hostStatus = [hostReachable currentReachabilityStatus];
  switch (hostStatus)
  
  {
      case NotReachable:
      {
          NSLog(@"A gateway to the host server is down.");
  
          break;
  
      }
      case ReachableViaWiFi:
      {
          NSLog(@"A gateway to the host server is working via WIFI.");
  
          break;
  
      }
      case ReachableViaWWAN:
      {
          NSLog(@"A gateway to the host server is working via WWAN.");
  
          break;
  
      }
  }
  </code></pre>
  
  <p>}</p>