zoukankan      html  css  js  c++  java
  • 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];

    }

  • 相关阅读:
    练习二十七:递归函数应用
    mysql8.0数据库忘记密码时进行修改方法
    格式化字符串两种方式
    练习二十六:阶乘计算(递归)
    练习二十五:阶乘之和计算
    Dapper批量添加
    c# FTP操作类(转)
    c# 依赖注入之---反射(转)
    c# 依赖注入之---setterInjection(转)
    php遍历数组赋值
  • 原文地址:https://www.cnblogs.com/wcLT/p/4734758.html
Copyright © 2011-2022 走看看