MrMaksimize
MrMaksimize

Reputation: 542

NSUser Defaults App Settings Doesn't store initial value

So I was wondering why this doesn't work. I have created a settings bundle, and really only have one text field in there for settings. I have given it a default value. However, If I clean the product, then build the app, I can't actually retrieve the default value, until I got into the settings on the emulator and change it to something else.

Is there a way to work around this?

Upvotes: 2

Views: 289

Answers (1)

Ben Mosher
Ben Mosher

Reputation: 13381

If you make a call to NSUserDefaults's -registerDefaults: method every time your app starts, it will initialize default settings (if the user has not visited the settings app).

If the user has set any settings, they will not be changed. This allows you to access your default values programmatically, though.

Documentation for the method can be found here.

Upvotes: 2

Related Questions