Reputation: 3433
I am storing some string value in NSUserDefaults,
In the next button click I need to edit stored value and save new string in the place of old string.
How can I do this.
Can any one please help me.
Thank you in advance.
Upvotes: 4
Views: 4817
Reputation: 1207
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
// getting an NSString
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"Password"];
[prefs setObject:@"" forKey:@"Password"];
NSString *passwordStr = [prefs stringForKey:@"Password"];
[[NSUserDefaults standardUserDefaults] synchronize];
Upvotes: 5
Reputation: 23722
[[NSUserDefaults standardUserDefaults] setObject: newStringValue forKey: kMyKey];
Upvotes: 9