I'm new to iOS development and am struggling to get the reachability.h class to work. Here is my code for view controller:
- (void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(checkNetworkStatus:)
name:kReachabilityChangedNotification
object:nil];
internetReachable = [Reachability reachabilityForInternetConnection];
[internetReachable startNotifier];
}
- (void)checkNetworkStatus:(NSNotification *)notice {
NetworkStatus internetStatus = [internetReachable currentReachabilityStatus];
NSLog(@"Network status: %i", internetStatus);
}
It looks ok but nothing is appearing in the xcode console when running the app and switching to that view.
I'm using Reachability 2.2 and iOS 4.2.
Is there something obvious that I am doing wrong?
See Question&Answers more detail:os