<!--
{
  "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/CFFileDescriptorCreate(_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Foundation"
    ],
    "preciseIdentifier" : "c:@F@CFFileDescriptorCreate"
  },
  "title" : "CFFileDescriptorCreate(_:_:_:_:_:)"
}
-->

# CFFileDescriptorCreate(_:_:_:_:_:)

Creates a new CFFileDescriptor.

```
func CFFileDescriptorCreate(_ allocator: CFAllocator!, _ fd: CFFileDescriptorNativeDescriptor, _ closeOnInvalidate: Bool, _ callout: CFFileDescriptorCallBack!, _ context: UnsafePointer<CFFileDescriptorContext>!) -> CFFileDescriptor!
```

## Parameters

`allocator`

The allocator to use to allocate memory for the new file descriptor object. Pass `NULL` or kCFAllocatorDefault to use the current default allocator.

`fd`

The file descriptor for the new CFFileDescriptor.

`closeOnInvalidate`

`true` if the new CFFileDescriptor should close `fd` when it is invalidated, otherwise `false`.

`callout`

The CFFileDescriptorCallBack for the new CFFileDescriptor.

`context`

Contextual information for the new CFFileDescriptor.

## Return Value

A new CFFileDescriptor or `NULL` if there was a problem creating the 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).

## See Also

[`CFFileDescriptorGetContext`](/documentation/CoreFoundation/CFFileDescriptorGetContext(_:_:))

Gets the context for a given CFFileDescriptor.

[`CFFileDescriptorInvalidate`](/documentation/CoreFoundation/CFFileDescriptorInvalidate(_:))

Invalidates a CFFileDescriptor 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)