NSUserDefaults key validation
NSUserDefaults key validation
- Subject: NSUserDefaults key validation
- From: Dan Huntsinger <email@hidden>
- Date: Fri, 16 Nov 2001 21:20:25 -0800
Hi all,
I have a routine that reads in my prefs, and I've got a bug in it. The
following code is an example of what I'm doing:
// load preferences
prefs = [NSUserDefaults standardUserDefaults];
// get show hints pref
// if no prefs have been set, set to default
if( [prefs boolForKey:@"ShowHintMessages"] != nil )
showHints = [prefs boolForKey:@"ShowHintMessages"];
else
showHints = NO;
My problem is this: since the key in this case is a BOOL, if it is set to
NO, then it will be interpreted as being nil. What I really need is a
method to check if a given key is valid(exists), but I don't see any such
method in the definition of NSUserDefualts. Does anyone have a suggestion
or a method they have used in this situation?
Thanks,
Dan