Reputation: 1820
I'm saving a few user settings in NSUserDefaults
. If these settings have not been modified by the user, I'd like the app to use presets.
How should I set this up so the app first checks if settings have been modified and if not, sets presets?
Checking if [[NSUserDefaults standardDefaults]objectForKey: @"setting1"] == nil
? Then setting a preset if it is not?
Upvotes: 0
Views: 142
Reputation: 187004
[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
Call that from your applicationDidFinishLaunchingWithOptions:
method that sets up whatever defaults you may need.
Upvotes: 4
Reputation: 104082
Look at the NSUserDefaults docs for registerDefaults. This allows you to have default values until the user changes them, then they have no effect.
Upvotes: 0