have to save UITextfield's value to the NSUserDefault and then send this value to server
i am trying this code .i jst want to save the value to NSUserDefault,trying to hold the value of NSUserDefault to local var val1, and later on have to send this value val1 to server, but when i run build the application ,username = null appears... m in big trouble..plzzzz help me out....alternate code would be apprecaited.....Thanx in advance
NSUserDefaults *username = [NSUserDefaults standardUserDefaults];
[username setObject:utextFieldNormal.text forKey:@"username"];
//NSLog(@"username:%@",ut开发者_运维百科extFieldNormal.text);
NSString *val1= [username valueForKey:@"username "];
NSLog(@"username:%@",val1);
[username synchronize]
[username valueForKey:@"username "];
You've seen the space there? @"username " != @"username"
. Maybe that's the source of your problem. And you should use objectForKey
instead of valueForKey
.
精彩评论