Re: /Library/Preferences
Re: /Library/Preferences
- Subject: Re: /Library/Preferences
- From: Chris Parker <email@hidden>
- Date: Thu, 10 Jul 2003 20:26:45 -0700
Hi Rhon,
On Thursday, July 10, 2003, at 7:04 PM, Rhon Fitzwater wrote:
I know I posted to both cocoa and student dev lists, but not everyone
is subscribed to both. :-)
Now for my question. Can anyone show me how to make it so my program
will write a preference to /Library/Preferences/. I know how to use
NSUserDefaults, but that creates a preference for every user that
opens my app. I just want one system wide preference. Only users
with admin privileges will be able to edit/save this system wide
preference, which is what I want.
Can someone post the simplest way to go about doing this?
You're looking for the CFPreferencesSetValue() API:
http://developer.apple.com/documentation/CoreFoundation/Reference/
CFPreferencesUtils/Reference/FunctionGroupIndex.html#//apple_ref/c/
func/CFPreferencesSetValue
which will let you set a preference key/value pair by using the
appropriate constants, like so:
CFPreferencesSetValue(key, value, kCFPreferencesCurrentApplication,
kCFPreferencesAnyUser, kCFPreferencesCurrentHost);
For more information on how the various constants correspond to
preferences domains on disk, you should probably check out
http://developer.apple.com/documentation/CoreFoundation/Conceptual/
CFPreferences/index.html
which has a discussion of when to use what domain triplet.
Note that the CFPreferencesSynchronize() will fail if your user doesn't
have privileges to write to /Library/Preferences (usually only admins
have this).
Keys set in this manner will still be picked up correctly by
NSUserDefaults' various methods.
.chris
--
Chris Parker
Cocoa Frameworks
Apple Computer, Inc.
_______________________________________________
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.