Does Apple's Reachability work with 3G connectivity?
Posted
by rickharrison
on Stack Overflow
See other posts from Stack Overflow
or by rickharrison
Published on 2010-04-15T13:18:25Z
Indexed on
2010/04/15
13:33 UTC
Read the original article
Hit count: 325
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?
© Stack Overflow or respective owner