Re: NSUserDefaults from within a bundle
Re: NSUserDefaults from within a bundle
- Subject: Re: NSUserDefaults from within a bundle
- From: Paul Collins <email@hidden>
- Date: Sun, 2 Jul 2006 11:25:01 -0700
On Jul 2, 2006, at 9:17 AM, Benjamin Einstein wrote:
We would really prefer to have global, "traveling" preferences
that are embedded in the application bundle but can be modified
locally (don't worry about rights, you must be a system admin and
an application admin to make preferences changes). Is there a way
to use NSUserDefaults to do this? Maybe CFPreferences?...
There's one major catch: the application would have to be copied
back when the user quits so other users get their updated
preferences. Hmmmm. It would be okay unless the write failed.
A few concepts that may be applicable, or not...
NSUserDefaults has "defaults domains" that have a precedence order:
the existence of a particular preference in one domain overrides that
pref in any lower domains (when you are getting the value of the pref
in your code). The "Registration" domain is lowest. It is hard coded
in your app (I do it in my app delegate's init method). These are
never changed (unless you release a new version of the whole app),
but are overridden by prefs in any other domain, such as when the
user changes a pref locally and it is stored in the user's
Preferences folder by NSUserDefaults.
Again, what Bill said about the app bundle--think of the app bundle
as read-only.
CFPreferences is the Core Foundation API to the *same* preferences
system as NSUserDefaults, but has lower-level flexibility. In
particular, it lets you write prefs to different places, in what are
called "Preference Domains" - which are completely different than
("orthogonal to") NSUserDefaults "Defaults Domains"! "Preference
Domains" includes an "any host" concept that you might like, although
I am not sure what the boundaries of this are (local network??).
You can read up on all this in the ADC reference library in Xcode's
built-in documentation.
In case you haven't figured this out yet: Cocoa's NS classes are
always the first place to look, but for some low-level or unusual
functionality you may need to drop down into Core Foundation's CF
functions, or even go over to Carbon (for certain GUI or event
functions that haven't made it into Cocoa).
One other thought: can you just put these shared "preferences" into
the SQL database?
Welcome to Mac programming, and good luck!
--Paul Collins
** Gracion Software LLC http://www.gracion.com/ **
** Tel: +1 (541) 488-3488 iChat/AV/AIM: gracionsoft **
** DigiTunnel 1.4 PPTP/VPN client for OS X **
** Pronto Patent - search/download US patents fast **
** And check out: http://www.opendoor.com/doorstop/ **
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden