tags:

views:

23

answers:

1

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:%@",utextFieldNormal.text);

NSString *val1= [username valueForKey:@"username "];

NSLog(@"username:%@",val1);

[username synchronize]

+1  A: 
[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.

V1ru8
Thank you So much V1ru8....
talktobijju
You're welcome.If I helped you then please accept my answer.
V1ru8
plz accept my questions plz coz whenever i ask any question regarding iPhone this msz appear on the screen "Sorry, we are no longer accepting questions from this account. "
talktobijju