title: iOS Reachability error will not display
body: <p>I have created an error message that should display if the user can not connect to google.com by either WI-FI or WWAN. I do not get any coding errors, so nothing seems to be wrong. I am using a UIWebview that goes to twitter.com. The issue may be that I am trying to get the error to display when the view loads and not the UIWebview, but I am not sure. Another issue that I am having is that I can not get "reachability" recognized as a name in the TwitterViewController.h file. Here is the code: </p>
  
  <p>TwitterViewController.h</p>
  
  <pre><code> #import &lt;UIKit/UIKit.h&gt;
      #import "Reachability.h"
  
      @interface TwitterViewController : UIViewController {
          Reachability *reachability;
  
      }
  
      @end
  </code></pre>
  
  <p>TwitterViewController.m</p>
  
  <pre><code>    #import "TwitterViewController.h"
      #import &lt;SystemConfiguration/SystemConfiguration.h&gt;
      #include &lt;netinet/in.h&gt;
  
      #import "TwitterView.h"
  
      @implementation TwitterViewController
  
      - (void)viewDidLoad  {
          [super viewDidLoad];
          Reachability *r = [Reachability reachabilityWithHostName:@"http://www.google.com"];
          NetworkStatus internetStatus = [r currentReachabilityStatus];
          if ((internetStatus != ReachableViaWiFi) &amp;&amp; (internetStatus != ReachableViaWWAN)) {
              UIAlertView *NEalert = [[UIAlertView alloc] initWithTitle: @"Error"
                                                                message: @"Could not load the webpage. Please check your internet connection."
                                                               delegate: nil
                                                      cancelButtonTitle: @"Dismiss"
                                                      otherButtonTitles: nil];       
              [NEalert show];
              [NEalert release];
  
          }
      }
  
      #pragma mark -
      #pragma mark Memory Management
  
      - (void)dealloc {
          [super dealloc];
      }
  
      #pragma mark -
      #pragma mark Initialisation
  
      - (id)init {
          self = [super init];
          if (self) {
              self.hidesBottomBarWhenPushed = YES;
  UINavigationBar objects
              self.title = @"Twitter";
  
              UIView *twitterView = [[TwitterView alloc] initWithParentViewController:self];
              self.view = twitterView;
  
              [twitterView release];
          }
          return self;
      }
  
      #pragma mark -
      #pragma mark Action Methods
  
      - (void)twitterBUTTONAction {
          UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"NFAGaming's Twitter"
                                                                message: @"To follow NFAGaming on twitter, go to: twitter.com/NFAGaming"
                                                               delegate: nil
                                                      cancelButtonTitle: nil
                                                      otherButtonTitles: @"Ok", nil];
          [alert show];
          [alert release];
      }
  
      #pragma mark -
      #pragma mark UIViewController Delegates
  
      - (void)didReceiveMemoryWarning {
          [super didReceiveMemoryWarning];
  
      }
  
      - (void)viewDidUnload {
          [super viewDidUnload];
      }
  
  
      @end
  </code></pre>
  
  <p>EDIT:
  This is what ended up working perfectly for me</p>
  
  <pre><code> {{Reachability *r = [Reachability reachabilityForInternetConnection];
          NetworkStatus internetStatus = [r currentReachabilityStatus];
          if (internetStatus == NotReachable) {
              UIAlertView *tNEalert = [[UIAlertView alloc] initWithTitle: @"Error"
                                                                 message: @"Internet Connection Required"
                                                                delegate: self
                                                       cancelButtonTitle: @"Dismiss"
                                                       otherButtonTitles: nil];       
              [tNEalert show];
              [tNEalert release];
          }
          else {
  
              UIView *twitterView = [[TwitterView alloc] initWithParentViewController:self];
              self.view = twitterView;
  
  
              [twitterView release];
  
          }
      }}
  </code></pre>