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

# CFURLDestroyResource(_:_:)

Destroys a resource indicated by a given URL.

```
func CFURLDestroyResource(_ url: CFURL!, _ errorCode: UnsafeMutablePointer<Int32>!) -> Bool
```

## Parameters

`url`

The `CFURL` object of the resource to destroy.

`errorCode`

On return, `0` if successful, otherwise an error code indicating the nature of the problem. See [`CFURLError`](/documentation/CoreFoundation/CFURLError) for a list of possible error codes.

## Return Value

`true` if successful, `false` otherwise.

## Discussion

If `url` uses an http scheme, an http `DELETE` request is sent to the resource. If `url` uses a file scheme, then:

- if the reference is a file, the file is deleted;
- if the reference is a directory and the directory is empty, the directory is deleted;
- if the reference is a directory and the directory is not empty, the function returns `false` and `errorCode` contains `kCFURLUnknownError`.

---

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)