---
title: "CFErrorCreate(_:_:_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cferrorcreate(_:_:_:_:)"
---

# CFErrorCreate(_:_:_:_:)

Creates a new CFError object.

## Declaration

```swift
func CFErrorCreate(_ allocator: CFAllocator!, _ domain: CFErrorDomain!, _ code: CFIndex, _ userInfo: CFDictionary!) -> CFError!
```

## Parameters

- `allocator`: The allocator to use to allocate memory for the new object. Pass NULL or doc://com.apple.corefoundation/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.
- `userInfo`: A CFDictionary created with doc://com.apple.corefoundation/documentation/CoreFoundation/kCFCopyStringDictionaryKeyCallBacks and doc://com.apple.corefoundation/documentation/CoreFoundation/kCFTypeDictionaryValueCallBacks. The dictionary is copied with doc://com.apple.corefoundation/documentation/CoreFoundation/CFDictionaryCreateCopy(_:_:). If you do not want the userInfo dictionary, you can pass NULL, in which case an empty dictionary will be assigned.

## Return Value

Return Value A new CFError object. Ownership follows the The Create Rule.

## See Also

### Creating a CFError

- [CFErrorCreateWithUserInfoKeysAndValues(_:_:_:_:_:_:)](corefoundation/cferrorcreatewithuserinfokeysandvalues(_:_:_:_:_:_:).md)
