I want to set some initial values for my NSUserDefault keys so that the first run of the app has some reasonable initial settings. I thought I ran across a simple way to do this in the app bundle .plist, but now I can’t find it. Any ideas?
Share
You should use the
registerDefaultsmethod ofNSUserDefaults. Prepare a plist file in your bundle that contains the default preferences and then use that plist to register the defaults.You have to execute this code on every launch of your app. It will add these values to a separate domain in the user defaults hierarchy. Whenever your app’s user defaults don’t provide a value for a certain key,
NSUserDefaultswill fall back to this domain and retrieve the value from there.