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

# CFURLSetResourcePropertyForKey(_:_:_:_:)

Sets the URL’s resource property for a given key to a given value.

```
func CFURLSetResourcePropertyForKey(_ url: CFURL!, _ key: CFString!, _ propertyValue: CFTypeRef!, _ error: UnsafeMutablePointer<Unmanaged<CFError>?>!) -> Bool
```

## Parameters

`url`

The URL.

`key`

The name of one of the URL’s resource properties.

`propertyValue`

The value for the resource property defined by `key`.

`error`

The error that occurred if the resource value could not be set.

## Return Value

`true`  if the resource property named `key` is successfully set to `value`; otherwise, `false`.

## Discussion

This function synchronously writes the new resource value out to disk. Attempts to set a read-only resource property or to set a resource property that is not supported by the resource are ignored and are not considered errors.

If an error occurs, this method returns `false` and populates the object pointer referenced by `error` with additional information.

> Note:
> This method applies only to URLs for file system resources.

## See Also

[`CFURL`](/documentation/CoreFoundation/CFURL)



---

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)