您的位置:首页 > 其它

NSUserDefaults 本地小量数据存储

2015-10-13 08:40 253 查看
  

1.在注册界面点击事件  把数据存进去

   NSUserDefaults *user = [NSUserDefaults standardUserDefaults];

    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:_ac1.text,@"name",_pw1.text,@"password", nil];

    [user setObject:dic forKey:@"user"];

    [self.navigationController popViewControllerAnimated:YES];

2.在登录界面 点击事件里 把数据取出来

  NSUserDefaults *user = [NSUserDefaults standardUserDefaults];

    NSDictionary *dic = [user objectForKey:@"user"];

    if ([_oneV.aa.text isEqualToString:[dic objectForKey:@"name"]] && [_oneV.bb.text isEqualToString:[dic objectForKey:@"passwaord"]]) {

        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@" 登录成功" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];

        [alert show];

    }else{

    

        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"登录失败" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定 ", nil];

        

        [alert show];

    

    }

   
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: