iOS 检测网络切换
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), //center
NULL, // observer
onNotifyCallback, // callback
CFSTR("com.apple.system.config.network_change"), // event name
NULL, // object
CFNotificationSuspensionBehaviorDeliverImmediately);
staticvoid onNotifyCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, constvoid *object, CFDictionaryRef userInfo)
{
NSString* notifyName = (__bridgeNSString*)name;
// this check should really only be necessary if you reuse this one callback method
// for multiple Darwin notification events
if ([notifyName isEqualToString:@"com.apple.system.config.network_change"]) {
}
}