Preferences using NSUserDefaults (newbie)
Preferences using NSUserDefaults (newbie)
- Subject: Preferences using NSUserDefaults (newbie)
- From: Jorge Salvador Caffarena <email@hidden>
- Date: Thu, 21 Jun 2001 12:10:02 +0200
Hello,
I am adding preferences support to my application using NSUserDefaults.
I looked at the tutorial found in cocoadevcentral.com, but it do not
work in my app.
For example they say that you can use this to check if the preferences
file exists:
if (! [NSUserDefaults standardUserDefaults] )
{
// create the default preferences
}
But the condition never evaluates to false, even if there are no
preferences file (a plist I suppose).
Also they show some code to initialize the preferences for the first
time, and they use this:
// create a dictionary
NSMutableDictionary *defaultPrefs = [NSMutableDictionary dictionary];
// put default prefs in the dictionary
[defaultPrefs setBool: YES forKey: somePrefOnOrOff];
// register the dictionary of defaults
[preferences registerDefaults: defaultPrefs];
NSLog(@"Registered defaults: %@", defaultValues);
But the compiler complaints here and says that "NSMutableDictionary do
not respond to setBool:forKey message".
So now I am really messed up, because this seems a easy and quick way of
implementing preferences, but I am unable to get it to work.
Thanks in advance,
Jorge Salvador Caffarena
http://homepage.mac.com/eevyl/