Th开发者_StackOverflowere's a NSUserDefault with Value:
[[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"aValue"];
Can it be overwritten by the another value? As:
[[NSUserDefaults standardUserDefaults] setObject:@"2" forKey:@"aValue"];
If yes what may be the pros and cons?
Yes, the value will be overwritten. NSUserDefaults is used to store information even after your app is closed.
This is often desired when you want to (for example in a game) increase the number of levels the user has completed.
The only disadvantage I see is that if you forget the name of a key, you might accidentally write over the value already there when you didn't intend to.
精彩评论