views:

125

answers:

1

So I was reading this: http://stackoverflow.com/questions/2228302/storing-iphone-application-settings-in-app which seems simple enough.

However, where/how would I define the initial settings?

So for instance I have a Country setting: UK or USA. When the app is first installed/opened I want it to automatically know/set NSUserDefaults to UK.

I hope this is clear ha.

Tom

+1  A: 

You can use the -registerDefaults: method to set up the "default defaults":

http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/UserDefaults/Tasks/UsingDefaults.html#//apple_ref/doc/uid/20000719-BAJFBAAH

quixoto
this seems ok, except I'm worried that if a user closes the app and then reopens it will it "reset" the settings? ie: if a user installs the app and changes their country to US I want it to remember that indefinitely. Will this work for that?
Thomas Clayson
I find the nomenclature in the API confusing. Registering defaults means providing actual default values. Anything you store in "standardUserDefaults" though should take precedence over the default-default. It's easy enough to test to reassure yourself. :)
quixoto