Skip navigation.
 
mlRe: NSUserDefaults from within a bundle
FROM : Paul Collins
DATE : Sun Jul 02 20:25:01 2006

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/          **

Related mailsAuthorDate
mlLengthy questions from a newbie beinstein Jun 20, 00:41
mlRe: Lengthy questions from a newbie Yorh Jun 20, 01:24
mlRe: Lengthy questions from a newbie colela Jun 20, 01:38
mlRe: Lengthy questions from a newbie James Bucanek Jun 20, 02:24
mlRe: Lengthy questions from a newbie Paul Lynch Jun 20, 18:39
mlRe: Lengthy questions from a newbie Keary Suska Jun 20, 18:44
mlRe: Lengthy questions from a newbie (and a new problem) Benjamin Einstein Jun 22, 01:26
mlRe: Lengthy questions from a newbie (and a new problem) Ryan Britton Jun 22, 01:39
mlRe: Lengthy questions from a newbie (and a new problem) Benjamin Einstein Jun 22, 01:45
mlRe: Lengthy questions from a newbie (and a new problem) Shaun Wexler Jun 22, 02:15
mlNSUserDefaults from within a bundle Benjamin Einstein Jul 2, 18:17
mlRe: NSUserDefaults from within a bundle Bill Bumgarner Jul 2, 19:03
mlRe: NSUserDefaults from within a bundle Paul Collins Jul 2, 20:25
mlRe: NSUserDefaults from within a bundle Benjamin Einstein Jul 2, 20:33