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

# CFErrorCreateWithUserInfoKeysAndValues(_:_:_:_:_:_:)

Creates a new CFError object using given keys and values to create the user info dictionary.

```
func CFErrorCreateWithUserInfoKeysAndValues(_ allocator: CFAllocator!, _ domain: CFErrorDomain!, _ code: CFIndex, _ userInfoKeys: UnsafePointer<UnsafeRawPointer?>!, _ userInfoValues: UnsafePointer<UnsafeRawPointer?>!, _ numUserInfoValues: CFIndex) -> CFError!
```

## Parameters

`allocator`

The allocator to use to allocate memory for the new object. Pass `NULL` or [`kCFAllocatorDefault`](/documentation/CoreFoundation/kCFAllocatorDefault) to use the current default allocator.

`domain`

A CFString that identifies the error domain. If this reference is `NULL` or is otherwise not a valid CFString, the behavior is undefined.

`code`

A CFIndex that identifies the error code. The code is interpreted within the context of the error domain.

`userInfoKeys`

An array of `numUserInfoValues` CFStrings used as keys in creating the userInfo dictionary. The value of this parameter can be `NULL` if `numUserInfoValues` is `0`.

`userInfoValues`

An array of `numUserInfoValues` CF types used as values in creating the userInfo dictionary.  The value of this parameter can be `NULL` if `numUserInfoValues` is `0`.

`numUserInfoValues`

The number of keys and values in the `userInfoKeys` and `userInfoValues` arrays.

## Return Value

A new CFError object. 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).

---

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)