Detect the reachability of network on iPhone

SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, "www.google.com");
SCNetworkReachabilityFlags flags;
BOOL success = SCNetworkReachabilityGetFlags(reachability, &flags);
BOOL isDataSourceAvailable = success && (flags & kSCNetworkFlagsReachable&& !(flags &kSCNetworkFlagsConnectionRequired);
CFRelease(reachability);

if(isDataSourceAvailable)
{
// Do some network things.
}


Learn More :