---
title: "CFPreferencesCopyValue(_:_:_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfpreferencescopyvalue(_:_:_:_:)"
---

# CFPreferencesCopyValue(_:_:_:_:)

Returns a preference value for a given domain.

## Declaration

```swift
func CFPreferencesCopyValue(_ key: CFString, _ applicationID: CFString, _ userName: CFString, _ hostName: CFString) -> CFPropertyList?
```

## Parameters

- `key`: Preferences key for the value to obtain.
- `applicationID`: The ID of the application whose preferences are searched. Takes the form of a Java package name, such as com.foosoft.
- `userName`: doc://com.apple.corefoundation/documentation/CoreFoundation/kCFPreferencesCurrentUser if to search the current-user domain, otherwise doc://com.apple.corefoundation/documentation/CoreFoundation/kCFPreferencesAnyUser to search the any-user domain.
- `hostName`: doc://com.apple.corefoundation/documentation/CoreFoundation/kCFPreferencesCurrentHost if to search the current-host domain, otherwise doc://com.apple.corefoundation/documentation/CoreFoundation/kCFPreferencesAnyHost to search the any-host domain.

## Return Value

Return Value The preference data for the specified domain. If the no value was located, returns NULL. Ownership follows the The Create Rule.

## Discussion

Discussion This function is the primitive get mechanism for the higher level preference function CFPreferencesCopyAppValue(_:_:) Unlike the high-level function, CFPreferencesCopyValue(_:_:_:_:) searches only the exact domain specified. Do not use this function directly unless you have a need. All arguments must be non-NULL. Do not use arbitrary user and host names, instead pass the pre-defined domain qualifier constants. Note that values returned from this function are immutable, even if you have recently set the value using a mutable object.

## See Also

### Getting Preference Values

- [CFPreferencesCopyAppValue(_:_:)](corefoundation/cfpreferencescopyappvalue(_:_:).md)
- [CFPreferencesCopyKeyList(_:_:_:)](corefoundation/cfpreferencescopykeylist(_:_:_:).md)
- [CFPreferencesCopyMultiple(_:_:_:_:)](corefoundation/cfpreferencescopymultiple(_:_:_:_:).md)
- [CFPreferencesGetAppBooleanValue(_:_:_:)](corefoundation/cfpreferencesgetappbooleanvalue(_:_:_:).md)
- [CFPreferencesGetAppIntegerValue(_:_:_:)](corefoundation/cfpreferencesgetappintegervalue(_:_:_:).md)
