Preference Domains

When creating a new preference or searching for an existing one, Preference Services uses the notion of preference domains to specify the scope and location of the preference. A preference domain is identified by three pieces of information: an application ID, a host name, and a user name. Table 1-1 shows all of the preference domains, listed in the order 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 (almost always using the constant kCFPreferencesCurrentApp ). The preference setting function uses as the default the current user and any host domain qualifiers, meaning that the standard location for application preferences is domain number two as listed in Table 1-1. The preference copy function searches the entire domain list in order. See the section 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. In most cases you will specify a domain using some combination of the domain qualifer enumeration constants. See the section Using the Low-Level Preferences API for information on using these functions.


© 2000 Apple Computer, Inc. (Last Updated 14 July 2000)