• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSUserDefaults key validation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >NSUserDefaults key validation (From: Dan Huntsinger <email@hidden>)

  • Prev by Date: Re: NSUserDefaults key validation
  • Next by Date: &xxx; thingies
  • Previous by thread: Re: NSUserDefaults key validation
  • Next by thread: Re: NSUserDefaults key validation
  • Index(es):
    • Date
    • Thread