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"]) {

}

}

上一篇:网页图片很多时,加载完后再加载图片(defer:延迟加载)


下一篇:WCF不支持 ASP.NET 兼容性 解决办法