• [NSUserDefaults]的使用:登陆后不再显示登录界面。


    简介:

    NSUserDefaults是IOS应用用来存储用户偏好和配置信息的途径,就像是一个数据库,但是它通过键值对(key-value)的方式存储。

    比如["Thematrix" forkey:"blogname"]

    使用方法:

    一共需要3个key,分别是"Didlogin" "username""userpassword"

    1.在AppDelegate的LaunchOption函数里:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    // Override point for customization after application launch.
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
    if(![[NSUserDefaults standardUserDefaults] boolForKey:@"Didlogin"]){
    NSLog(@"未进行过登录,进行登录");
    LoginViewController *LoginViewController =[storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
    self.window.rootViewController = LoginViewController;
    }
    else
    {
    NSLog(@"已经进行过登录,直接到首页");
    IndexViewController * IndexViewController = [storyboard instantiateViewControllerWithIdentifier:@"IndexViewController"];
    self.window.rootViewController = IndexViewController;
    }
    return YES;
    }
  • 相关阅读:
    win10新特性,ubuntu子系统(安装及配置)
    excel计算后列填充
    word中利用宏替换标点标点全角与半角
    CFD-post的奇技淫巧
    mfix模拟流化床燃烧帮助收敛的方法
    cygwin下配置alias
    endnote 使用方法
    win8系统换win7系统
    python中的函数以及递归
    01python算法--算法和数据结构是什么鬼?
  • 原文地址:https://www.cnblogs.com/zhaoweizheng/p/4599852.html
Copyright © 2020-2023  润新知