Preference Domains

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.

Table 1  Preference Domains in search order

1

Current User

Current Application

Current Host

2

Current User

Current Application

Any Host

3

Current User

Any Application

Current Host

4

Current User

Any Application

Any Host

5

Any User

Current Application

Current Host

6

Any User

Current Application

Any Host

7

Any User

Any Application

Current Host

8

Any User

Any Application

Any Host

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.

Domain Qualifiers

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.