How to insert only one username and password in SQLite database?

前端 未结 5 1006
鱼传尺愫
鱼传尺愫 2020-12-12 03:55

I have an application where I have two textfields and a button. In the first textfield I am entering the username of the user and in the second textfield I am entering the p

5条回答
  •  囚心锁ツ
    2020-12-12 04:12

    You can use NSUserDefaults saving locally it. following code is for saving data.

     perf = [NSUserDefaults standardUserDefaults];
     [perf setObject:@"1" forKey:@"remember"];
     [perf setObject:emailAddresTextField.text forKey:@"email"];
     [perf setObject:passwordTextField.text forKey:@"password"];
     [perf synchronize];
    

    And for retrieving data use following code

    perf=[NSUserDefaults standardUserDefaults];
    NSString *remString = [perf stringForKey:@"remember"];  
    
    if ([remString isEqualToString:@"1"]) {
        emailAddresTextField.text=[perf stringForKey:@"email"];
        passwordTextField.text = [perf stringForKey:@"password"];
        [rememberBtn setTag:1];
        [rememberBtn setImage:[UIImage imageNamed:@"on_radioButton.png"] forState:0];
    }
    

提交回复
热议问题