• 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];
        }
    }

  • 相关阅读:
    pipeline流水线语法格式
    nexus私服配置npm、nuget、pypi
    正则表达式-grep
    awk 经典案例
    nginx安装,配置,及高可用
    git remote add origin错误
    [转]Git 撤销操作
    [转]git命令之git remote的用法
    [转]git学习------>git-rev-parse命令初识
    转 gerrit
  • 原文地址:https://www.cnblogs.com/chenfulai/p/2124982.html
Copyright © 2020-2023  润新知