开发者

NSUSERDefaults class HAVE PROBLEM OR NOT?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜