<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreFoundation",
  "identifier" : "/documentation/CoreFoundation/CFPreferencesCopyValue(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFPreferencesCopyValue"
  },
  "title" : "CFPreferencesCopyValue(_:_:_:_:)"
}
-->

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

Returns a preference value for a given domain.

```
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`

[`kCFPreferencesCurrentUser`](/documentation/CoreFoundation/kCFPreferencesCurrentUser) if to search the current-user domain, otherwise [`kCFPreferencesAnyUser`](/documentation/CoreFoundation/kCFPreferencesAnyUser) to search the any-user domain.

`hostName`

[`kCFPreferencesCurrentHost`](/documentation/CoreFoundation/kCFPreferencesCurrentHost) if to search the current-host domain, otherwise [`kCFPreferencesAnyHost`](/documentation/CoreFoundation/kCFPreferencesAnyHost) to search the any-host domain.

## Return Value

The preference data for the specified domain. If the no value was located, returns `NULL`. Ownership follows the [The Create Rule](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html#//apple_ref/doc/uid/20001148-103029).

## Discussion

This function is the primitive get mechanism for the higher level preference function [`CFPreferencesCopyAppValue(_:_:)`](/documentation/CoreFoundation/CFPreferencesCopyAppValue(_:_:)) Unlike the high-level function, [`CFPreferencesCopyValue(_:_:_:_:)`](/documentation/CoreFoundation/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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)