NSUserDefaults - reload needed?
I use NSUserDefaults to store some stuff.
It works fine but only after i restart the app.
I use: [prefs synchronize]; I thought it would immediately save the data but instead preferences stay null.
If you have any idea or already de开发者_开发技巧al with it let me know. Thanks for any help.
Wallou
I finally managed to solve my issue. I was doing the same thing at two different places (old code forgotten somewhere). For information here is my code:
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
// saving an NSString
[prefs setObject:identField.text forKey:@"mail"];
[prefs setObject:pwdField.text forKey:@"password"];
mail=[prefs objectForKey:@"mail"];
pwd=[prefs objectForKey:@"password"];
//This is to synch prefs
[prefs synchronize];
NSLog(@"pwd: %@, username:%@", mail, pwd);
精彩评论