Does Apple's Reachability work with 3G connectivity?
- by rickharrison
I am developing an iPad application, and I am trying to figure out the best way to decide if a user can connect to the Internet. If the user has no connectivity, I will load cached data, otherwise I will load new data. I am trying to use Apple's reachability class for this, and I wanted to see if I am doing this correctly. In applicationDidFinishLaunchingWithOptions, I am doing this:
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(reachabilityChanged:) name: kReachabilityChangedNotification object: nil];
Reachability hostReach = [[Reachability reachabilityWithHostName: @"www.apple.com"] retain];
[hostReach startNotifer];
Then my reachabilityChanged: looks like this:
- (void)reachabilityChanged:(NSNotification* )note {
Reachability *curReach = [note object];
self.internetConnectionStatus = [curReach currentReachabilityStatus];
if (internetConnectionStatus == NotReachable) {
[viewController getDataOffline];
} else {
if (![[NSUserDefaults standardUserDefaults] objectForKey:kFIRST_LAUNCH]) [viewController getCurrentLocation];
else [viewController getData];
}
}
Right now, this is working perfectly for WiFi iPads. I just want to make sure that this will work for 3G iPads. Could you please let me know if I am doing this correctly or not?