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

# CFFileDescriptorInvalidate(_:)

Invalidates a CFFileDescriptor object.

```
func CFFileDescriptorInvalidate(_ f: CFFileDescriptor!)
```

## Parameters

`f`

A CFFileDescriptor.

## Discussion

Once invalidated, the CFFileDescriptor object will no longer be read from or written to at the Core Fundation level.

If you passed `true` for the `closeOnInvalidate` parameter when you called [`CFFileDescriptorCreate(_:_:_:_:_:)`](/documentation/CoreFoundation/CFFileDescriptorCreate(_:_:_:_:_:)), this function also closes the underlying file descriptor. If you passed `false`, you must close the descriptor yourself *after* invalidating the CFFileDescriptor object.

> Important:
> You must invalidate the CFFileDescriptor before closing the underlying file descriptor.

## See Also

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

Returns the native file descriptor for a given CFFileDescriptor.

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

Returns a Boolean value that indicates whether the native file descriptor for a given CFFileDescriptor is valid.



---

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)