Let me first emphasize the fact that I'm talking about the Mac OS X SDK, not the iPhone.
To define a "connection" and get the flags, I do something similar to:
#import <SystemConfiguration/SystemConfiguration.h>
const char *hostName = [@"google.com" cStringUsingEncoding:NSASCIIStringEncoding];
SCNetworkReachabilityRef target = SCNetworkReachabilityCreateWithName(NULL, hostName);
SCNetworkConnectionFlags flags = 0;
SCNetworkReachabilityGetFlags(target, &flags);
It’s good for this to get Google accessibility information (that’s what I want to know).
Is there a way to add an observer to the changes? I looked SCDynamicStore, but I found a single example from Apple and the documentation is a bit overwhelming.
Ideally, I would like to be able to set a function for flag changes, but that will be enough: pay attention when the IP is “dropped” / released and when it will be received. (Then I could make reachability hard-coded into a function that fires when an IP is received).
Please feel free to ask for development.
source
share