Created
October 31, 2012 16:59
-
-
Save swarut/3988292 to your computer and use it in GitHub Desktop.
Objective-C : Using UserPreference #objective-c #userpreference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
userPreference = [NSUserDefaults standardUserDefaults]; | |
// Check for a value of a specific key | |
if([userPreference objectForKey:@"login_info"]){ | |
NSString *userInfo = [userPreference objectForKey:@"login_info"]; | |
NSArray *tokens = [userInfo componentsSeparatedByString:@"/"]; | |
[self.telephoneTextField setText:[tokens objectAtIndex:0]]; | |
[self.passwordTextField setText:[tokens objectAtIndex:1]]; | |
[self login:self]; | |
} | |
// save login so that the user doesn't have to input login info again | |
if([userPreference objectForKey:@"login_info"] == nil){ | |
NSString *user_info = [NSString stringWithFormat:@"%@/%@", telephoneTextField.text, passwordTextField.text]; | |
[userPreference setValue:user_info forKey:@"login_info"]; | |
[userPreference synchronize]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment