Created
August 12, 2011 10:37
-
-
Save pratikshabhisikar/1141833 to your computer and use it in GitHub Desktop.
Saving username and password in userdefaults
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
#define USERNAME_KEY @"username" | |
#define PASSWORD_KEY @"password" | |
-(void) saveUser:(NSString *) username andPassword:(NSString *) password { | |
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; | |
// Save the username. | |
[userDefaults setObject:username forKey:USERNAME_KEY]; | |
[userDefaults synchronize]; | |
// Save the password. | |
[userDefaults setObject:password forKey:PASSWORD_KEY]; | |
[userDefaults synchronize]; | |
} | |
-(void) someFunction { | |
NSString *username = [[NSUserDefaults standardUserDefaults] objectForKey:USERNAME_KEY]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment