Csabi
Csabi

Reputation: 3043

How can I update data for a key using NSUserDefaults

Hi i want to update data for key but it still stays the same my code is:

NSUserDefaults *userNamePrefs = [NSUserDefaults standardUserDefaults];

    [userNamePrefs removeObjectForKey:@"mykey"];

    [userNamePrefs setObject:@"myNewStringValue" forKey:@"mykey"];

but it does not works it does not remove object and ignore to add new value for key, please help what am i missing

thanks

Upvotes: 1

Views: 5181

Answers (1)

Vladimir
Vladimir

Reputation: 170829

Try calling

[userNamePrefs synchronize];

after you made your updates

Upvotes: 12

Related Questions