views:

71

answers:

1

hey guys,

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 deal with it let me know. Thanks for any help.

Wallou

A: 

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);

wallou