NSString *string = @"Hardwork";
NSUserDefaults* defs111 = [NSUserDefaults standardUserDefaults];
[defs111 setObject:string forKey:@"first_name_textfiel开发者_Go百科d"];
Hi, In my code I'm unable to set this value string for key first_name_textfield. Why is it,so?
I have used this code to save and retrieve the values using NSUserDefaults. So refer this ,it will help you.
IBOutlet UITextField * username;
IBOutlet UITextField * password;
NSString *userNameString;
NSString *passWordString;
userNameString = [[NSString alloc] initWithFormat:[username text]];
[username setText:userNameString];
NSUserDefaults *usernamedefaults = [NSUserDefaults standardUserDefaults];
[usernamedefaults setObject:userNameString forKey:@"StringKey"];
passWordString = [[NSString alloc] initWithFormat:[password text]];
[password setText:passWordString];
NSUserDefaults *passworddefaults = [NSUserDefaults standardUserDefaults];
[passworddefaults setObject:passWordString forKey:@"StringKey1"];
Thanks.
精彩评论