NSUserDefaults question
NSUserDefaults question
- Subject: NSUserDefaults question
- From: Angela Brett <email@hidden>
- Date: Tue, 5 Mar 2002 23:31:42 +1300
Hi,
I have several applications which share many of their settings. I
know that with NSUserDefaults I can use addSuiteNamed:,
persistentDomainForName: and setPersistentDomain:forName: in order to
read and write defaults in a shared defaults file.
As I understand it, if I addSuiteNamed:@"My Main Defaults thingy"
then when I use objectForKey: or one of those methods, it should
return the object for that key in the @"My Main Defaults thingy"
domain, or if there isn't one, the object for that key in the
app-specific defaults. However, it seems the only way to write a
default to @"My Main Defaults thingy" (using NSUserDefaults, anyway)
is to do something like:
NSMutableDictionary *mainDefaults=[[[NSUserDefaults
standardUserDefaults] persistentDomainForName: @"My Main Defaults
thingy"] mutableCopy];
[mainDefaults setObject:myObject forKey:myKey];
[[NSUserDefaults standardUserDefaults]
setPersistentDomain:mainDefaults forName: @"My Main Defaults thingy"];
[mainDefaults release];
which is quite a bit more complicated than just using
[[NSUserDefaults standardUserDefaults] setObject:myObject
forKey:myKey] which I would do to save a default to the specific
defaults for that app.
I know that I could do it in one line with
CFPreferencesSetAppValue((CFStringRef)myKey,myObject,CFSTR("My Main
Defaults thingy"));
So, if there is a simple one-line way of changing a single default
for the app name of my choice in CoreFoundation, how come there isn't
a method like that in NSUserDefaults? Or is there one, and I just
haven't see it?
--
Angela Brett email@hidden
http://acronyms.co.nz/angela
A mathematician is a machine for turning coffee into theorems -- Paul Erdos
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.