/ Published in: Objective C
taken from apple source code -- seismic sample application
worth mentioning: they only check for connectivity once -- invoking performance as the reason
Expand |
Embed | Plain Text
static BOOL checkNetwork = YES; if (checkNetwork) { // Since checking the reachability of a host can be expensive, cache the result and perform the reachability check once. checkNetwork = NO; Boolean success; const char *host_name = "earthquake.usgs.gov"; SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, host_name); SCNetworkReachabilityFlags flags; success = SCNetworkReachabilityGetFlags(reachability, &flags); _isDataSourceAvailable = success && (flags & kSCNetworkFlagsReachable) && !(flags & kSCNetworkFlagsConnectionRequired); CFRelease(reachability); } return _isDataSourceAvailable;
Comments
Subscribe to comments
You need to login to post a comment.

Requires System.Configuration framework