My iphone application is pretty simple with one view that handles everything, in viewDidLoad I check if we have an internet connection, and if we download from the Internet, and if we do not download it from a local resource. And it works great.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleNetworkChange:)
name:kReachabilityChangedNotification object:nil];
reachability = [Reachability reachabilityForInternetConnection];
[reachability startNotifier];
NetworkStatus status = [reachability currentReachabilityStatus];
if (status == NotReachable) {
} else {
}
- (void)handleNetworkChange:(NSNotification *)notice{
NetworkStatus status = [reachability currentReachabilityStatus];
if (status == NotReachable) {
} else {
}
}
To check the handleNetworkChange event, I turned off all cellular data, but turned off Wi-Fi. In the Wi-Fi range, I started the application and everything works fine. Then I go beyond the wifi range, but my handleNetworkChange never fires (tested using uiAlertView). Standing outside the Wi-Fi range, my app launches an offline message just fine.
, ViewController, AppDelegate? , .