Preferences Utilities

Overview

Several functions return a preference value as a Core Foundation property list object. You can use the function CFGetTypeID to determine the value’s type. For more information about property lists, see Property List Programming Topics for Core Foundation.

Overview

Core Foundation provides a simple, standard way to manage user (and application) preferences. Core Foundation stores preferences as key-value pairs that are assigned a scope using a combination of user name, application ID, and host (computer) names. This makes it possible to save and retrieve preferences that apply to different classes of users. Core Foundation preferences is useful to all applications that support user preferences. Note that modification of some preferences domains (those not belonging to the “Current User”) requires root privileges (or Admin privileges prior to OS X v10.6)—see Authorization Services Programming Guide for information on how to gain suitable privileges.

Unlike some other Core Foundation types, CFPreferences is not toll-free bridged to its corresponding Cocoa Foundation framework class (NSUserDefaults). CFPreferences is thread-safe.

Topics

Getting Preference Values

CFPreferencesCopyAppValue

Obtains a preference value for the specified key and application.

CFPreferencesCopyKeyList

Constructs and returns the list of all keys set in the specified domain.

CFPreferencesCopyMultiple

Returns a dictionary containing preference values for multiple keys.

CFPreferencesCopyValue

Returns a preference value for a given domain.

CFPreferencesGetAppBooleanValue

Convenience function that directly obtains a Boolean preference value for the specified key.

CFPreferencesGetAppIntegerValue

Convenience function that directly obtains an integer preference value for the specified key.

Setting Preference Values

CFPreferencesSetAppValue

Adds, modifies, or removes a preference.

CFPreferencesSetMultiple

Convenience function that allows you to set and remove multiple preference values.

CFPreferencesSetValue

Adds, modifies, or removes a preference value for the specified domain.

Synchronizing Preferences

CFPreferencesAppSynchronize

Writes to permanent storage all pending changes to the preference data for the application, and reads the latest preference data from permanent storage.

CFPreferencesSynchronize

For the specified domain, writes all pending changes to preference data to permanent storage, and reads latest preference data from permanent storage.

Adding and Removing Suite Preferences

CFPreferencesAddSuitePreferencesToApp

Adds suite preferences to an application’s preference search chain.

CFPreferencesRemoveSuitePreferencesFromApp

Removes suite preferences from an application’s search chain.

Miscellaneous Functions

CFPreferencesAppValueIsForced

Determines whether or not a given key has been imposed on the user.

CFPreferencesCopyApplicationList

Constructs and returns the list of all applications that have preferences in the scope of the specified user and host.

Deprecated

Constants

Application, Host, and User Keys

Keys used to specify the common preference domains.