- (void)viewDidLoad
{
//...
BOOL anBool = [[NSUserDefaults standardUserDefaults]boolForKey:@"SwitchON"];
if (anBool) {
NSLog(@"anBool == Yes");
anSwitch.on = YES;
nameTextField.text = [[NSUserDefaults standardUserDefaults]objectForKey:@"UserName"];
passworldTextField.text = [[NSUserDefaults standardUserDefaults]objectForKey:@"PassWord"];
}
}
- (IBAction) doLogin
{
//。。。。。。
if (anSwitch.on) {
[[NSUserDefaults standardUserDefaults]setBool:anSwitch.on forKey:@"SwitchON"];
[[NSUserDefaults standardUserDefaults]setObject:nameTextField.text forKey:@"UserName"];
[[NSUserDefaults standardUserDefaults]setObject:passworldTextField.text forKey:@"PassWord"];
}else {
[[NSUserDefaults standardUserDefaults]setBool:anSwitch.on forKey:@"SwitchON"];
}
}