zoukankan      html  css  js  c++  java
  • oc中检测网络状态

        // 监测网络情况
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(reachabilityChanged:)
                                                     name: kReachabilityChangedNotification
                                                   object: nil];
        hostReach = [[Reachability reachabilityWithHostName:@"www.google.com"] retain];

        [hostReach startNotifier];

    - (void)reachabilityChanged:(NSNotification *)note {
        Reachability* curReach = [note object];
        NSParameterAssert([curReach isKindOfClass: [Reachability class]]);
        NetworkStatus status = [curReach currentReachabilityStatus];

        if (status == NotReachable) {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"AppName"
                                  message:@"NotReachable"
                                  delegate:nil
                                  cancelButtonTitle:@"YES" otherButtonTitles:nil];
                                  [alert show];
                                  [alert release];
        }
    }

  • 相关阅读:
    求整数数组(长度为n),出现大于2/n次数的数字
    Job-Show Liang,你来掌管诺基亚王国,可好?
    wp面试题
    启动 Windows Phone 8 内置应用的 URI 方案
    .Net高级面试宝典
    JDK和Tomcat部署
    HAproxy功能配置
    配置HAProxy支持https协议
    Tomcat Cluster负载均衡
    Tomcat会话保持之session server
  • 原文地址:https://www.cnblogs.com/chenfulai/p/2124982.html
Copyright © 2011-2022 走看看