-(BOOL)connected
{
Reachability *reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [reachability currentReachabilityStatus];
return !(networkStatus == NotReachable);
}
if (![self connected]) {
NSLog(@"Not Connected");
} else {
NSLog(@"Connected");
// connected, do some internet stuff
}
The above code is perfectly working with Wifi.When i use 3G connectivity it is not working correctly.I do not know how to change code for 3G connectivity.any help will be appreciated.thanks in advance.
Reachability is only used to detect if a system has connection to a gateway to the internet but doesn't go in-depth and check whats behind it. There a times when a LAN is reachable but there no gateway to the internet. You're have to make a actual real request to a server. Take a look at this great sample code on how to implement on all types of connectivity