When creating a new preference or searching for an existing one, Core Foundation uses the notion of “Preference Domains” to specify the scope and location of the preference. A preference domain consists of three pieces of information, an application ID, a host name, and a user name. Table 1 shows all of the preference domains, listed in the order that they are searched when attempting to locate a preference value.
When using the high-level preferences functions CFPreferencesSetAppValue
, and CFPreferencesCopyAppValue
, you need only specify the application ID. The first function, CFPreferencesSetAppValue
, places the preference value into the “Current User” and “Any Host” domain for the application, meaning that the standard location for application preferences is domain number two as listed in Table 1. The other function, CFPreferencesCopyAppValue
, searches through all the domains in order until a value is found. See “Using the High-Level Preferences API” for information on using these functions.
If you need to specify an exact domain for your preference values you can use the low-level preferences functions CFPreferencesSetValue
, and CFPreferencesCopyValue
. These functions allow you to specify all three of the domain qualifiers when setting or searching for preferences. When using these functions you cannot pass arbitrary host and user names; you must instead use the appropriate “Any” or “Current” constants given in the list below. For the application domain qualifier, you can either pass the application ID or one of the “Any” or “Current” application constants given in the list below. See “Using the Low-Level Preferences API” for information on using these functions.
kCFPreferencesAnyApplication | Indicates a preference that applies to any application. |
kCFPreferencesCurrentApplication | Indicates a preference that applies only to the current application. |
kCFPreferencesAnyHost | Indicates a preference that applies to any host. |
kCFPreferencesCurrentHost | Indicates a preference that applies only to the current host. |
kCFPreferencesAnyUser | Indicates a preference that applies to any user. |
kCFPreferencesCurrentUser | Indicates a preference that applies only to the current user. |
Last updated: 2006-10-03