开发者

Can NSUserDefault be overwritten?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜