Re: NSUserDefaults key validation
Re: NSUserDefaults key validation
- Subject: Re: NSUserDefaults key validation
- From: Mike Shields <email@hidden>
- Date: Fri, 16 Nov 2001 23:39:07 -0700
You solve this by registering default defaults.
Add an +initialize method to you application delegate or some other
class - basically wherever that you will be using it, put it in the
initialize method of that class.
+ (void) initialize
{
if (self == [MyClass class])
{
NSMutableDictionary* defaults = [NSMutableDictionary dictionary];
[defaults setObject:@"NO" forKey:@"ShowHintMessages"];
[[NSUserDefaults standardUserDefaults] registerDefaults: defaults];
}
}
Then when you go to get the defaults, you'll always have a default value
if the user has not set one herself.
Mike