zoukankan      html  css  js  c++  java
  • iOS-检测网络可连接性

    #pragma mark - 监测网络的可链接性
    + (void)netWorkReachabilityWithURLString:(NSString *)strUrl
    {
        AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:strUrl]];
        [manager.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
            switch (status) {
                case AFNetworkReachabilityStatusUnknown:
                case AFNetworkReachabilityStatusNotReachable: {
                    [[NSNotificationCenter defaultCenter] postNotificationName:DMNetworkInvalidNotification object:nil];
                    UIAlertView *networkAlterView = [[UIAlertView alloc] initWithTitle:@"当前网络不可用,请检查您的网络设置。"
                                                                               message:nil
                                                                              delegate:self
                                                                     cancelButtonTitle:@"好"
                                                                     otherButtonTitles:nil, nil];
                    [networkAlterView show];
                }
                    break;
                case AFNetworkReachabilityStatusReachableViaWWAN:
                    [[NSNotificationCenter defaultCenter] postNotificationName:DMNetworkActiveNotification object:nil];
                    break;
                case AFNetworkReachabilityStatusReachableViaWiFi:
                    [DMTools HUDError:DMRequestWIFINote toView:DMWindow];
                    [[NSNotificationCenter defaultCenter] postNotificationName:DMNetworkActiveNotification object:nil];
                    break;
            }
        }];
        [manager.reachabilityManager startMonitoring];
  • 相关阅读:
    spring容器与java访问权限的关系!
    Mybatis初始化过程详解
    Spring-boot 一些常用注解说明!
    JNDI + Spring 如何读取数据
    HashMap,,ConcurrentHashMap------------------浅谈!!
    spring ioc容器和spring mvc 容器--------浅谈!!
    针对xml文件做提取与写入的操作
    vim编辑器显示行号
    ubuntu双系统修复windows引导
    git基本操作
  • 原文地址:https://www.cnblogs.com/linxiu-0925/p/5086169.html
Copyright © 2011-2022 走看看