title: iOS Reachability: Problem with host Method
body: <p>I have create a method to check if the host is reachable.  I had download  the Reachability class (both .h &amp; .m) from apple developer websites and import to my project.  I have pass the NSString Name as the URL (host Name).  The hostName is <a href="http://www.google.com" rel="nofollow">http://www.google.com</a>. However, no matter what host name I pass to this method and its always return NO (connectToHost). The code as below:</p>
  
  <pre><code>- (BOOL) checkHostAvailability:(NSString *)Name{
          BOOL connectToHost;
          hostReach = [[Reachability reachabilityWithHostName:Name] retain];
          [hostReach startNotifier];
  
          NetworkStatus hostStatus = [hostReach currentReachabilityStatus];
          NSLog(@"Name: %@", Name);
          NSLog(@"hostStatus is %@", hostStatus);
  
          if(hostStatus == NotReachable){
                  NSLog(@"Here is the checkHostAvailability Method and host NOT reachable");
                  connectToHost = NO;
         }else{
                  NSLog(@"Here is the checkHostAvailability Method and host is reachable");
                  connectToHost = YES;
         }
         return connectToHost;
  
  
  }
  </code></pre>
  
  <p>After a few hours of investigation, I have found out that the NetworkStatus hostStatus always  equal to null.  I assume this is why this method is not working.  And I have spend 8 hours to find out the problem with this code and search out this website, however I still couldn't find the problem and solution.  </p>
  
  <p>Please help and much appreciated.   </p>