views:

7

answers:

1

I set a text setting key in by Settings.bundle. The Settings app show the key's default value well. But I can't read the value via NSUserDefaults with this code.

NSString *aaa   =   [[[NSUserDefaults standardUserDefaults] stringForKey:@"aaa"] copy];

Value is always nil. I believe I omitted something required steps. What's required?

A: 

I got solution.

Settings.bundle is just for configuration of Settings app, and the default values designated in the file is only for Settings app UI. So the NSUserDefaults does not read them automatically. At the first time of your app launch, there is no default configuration. So you have to create default values yourself.

I don't remember about execution of Settings app before first launch. As I remember. However, it's obvious you have to offer default value via code if the entries are not exist.

Eonil