• IOS之网络状态设和NSUserDefaults的synchronize


    #pragma mark - check net status

    int apiCheckNetStatus()

    {

        Reachability *reachNet = [Reachability reachabilityWithHostName:@"www.apple.com"];//www.newsmth.net

        int retNetStatus = -1;

        switch ([reachNet currentReachabilityStatus]) {

            case NotReachable:

                retNetStatus = -1;

                break;

            case ReachableViaWWAN:

                retNetStatus = 0;

                break;

            case ReachableViaWiFi:

                retNetStatus = 1;

                break;            

            default:

                break;

        }

        

        return retNetStatus;

    }

     

    -(void)load_setting

    {

        NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];

        

        attachment_images_size = [[defaults objectForKey:@"attachment_images_size"] intValue];

        upphoto_size = [[defaults objectForKey:@"upphoto_size"] intValue];

        brcmode = [[defaults objectForKey:@"brcmode"] intValue];

        

        strUsr = [defaults objectForKey:@"username"];

        strPwd = [defaults objectForKey:@"password"];

     

        my_notify_number = [(NSString *)[defaults objectForKey:@"my_notify_number"] intValue];

        my_dismiss_version = [defaults objectForKey:@"dismiss_version"];

        

        font_size = [(NSString *)[defaults objectForKey:@"font_size"] intValue];

        if(font_size < 8 || font_size > 32){

            font_size = 16;

        }

        

        article_sort = [(NSString *)[defaults objectForKey:@"article_sort"] intValue];

        

        order_threadid = [(NSString *)[defaults objectForKey:@"order_threadid"] intValue];

    }

     

    -(NSString *)getLoginInfoUsr

    {

        return strUsr;

    }

     

    -(NSString *)getLoginInfoPwd

    {

        return strPwd;

    }

     

    -(void)appSettingChange:(NSString *)name :(NSString *)value

    {

        NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];

        [defaults setObject:value forKey:name];

        [defaults synchronize];

        

        [self load_setting];

    }

  • 相关阅读:
    吴裕雄--天生自然JAVA图形界面编程学习笔记:单选按钮JRadioButton
    (001)springboot中测试的基础知识以及接口和Controller的测试
    (029)Spring Boot之监测与度量
    (028)Spring Boot之日志处理
    (027)Spring Boot之自定义starter
    (026)Spring Boot之aop
    (025)Spring Boot之JdbcTemplate与Transactional事务处理
    (024)Spring Boot之配置数据源
    (023)Spring Boot之修改内嵌tomcat的3种方式
    (022)Spring Boot之异常处理的两种方式
  • 原文地址:https://www.cnblogs.com/wcLT/p/4734758.html
Copyright © 2020-2023  润新知