[Via]
This code tells you if you have a network connection. You need the Reachability class from Apple.
#import "Reachability.h" |
+( BOOL ) doWeHaveInternetConnection{ |
Reachability *hostReach = [[Reachability reachabilityWithHostName: @"www.google.com"] retain]; |
NetworkStatus netStatus = [hostReach currentReachabilityStatus]; |
if (netStatus == NotReachable) |
NSLog (@"NotReachable"); |
if (netStatus == ReachableViaWiFi) |
NSLog (@"ReachableViaWiFi"); |
if (netStatus == ReachableViaWWAN) |
NSLog (@"ReachableViaWWAN"); |