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

# CFURLWriteDataAndPropertiesToResource(_:_:_:_:)

Writes the given data and properties to a given URL.

```
func CFURLWriteDataAndPropertiesToResource(_ url: CFURL!, _ dataToWrite: CFData!, _ propertiesToWrite: CFDictionary!, _ errorCode: UnsafeMutablePointer<Int32>!) -> Bool
```

## Parameters

`url`

The resource to write.

`dataToWrite`

The data to write. Pass `NULL` to write only properties.

`propertiesToWrite`

The properties to write. Pass `NULL` to write only data. See [File URL Properties](/documentation/CoreFoundation/file-url-properties) and [HTTP URL Properties](/documentation/CoreFoundation/http-url-properties) for the list of available properties.

`errorCode`

Upon return, `0` if successful, otherwise contains 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

Properties not present in `propertiesToWrite` are left unchanged, hence if `propertiesToWrite` is `NULL` or empty, the URL’s properties are not changed at all.

If `url` uses a file scheme and it references a file, the contents of `dataToWrite` are written to the referenced file, overwriting any preexisting data, and the file’s properties are modified according to `propertiesToWrite`. If the file does not exist, but all intermediate directories along the path do already exist, the file is created (otherwise it is not).

If `url` uses a file scheme and it references a directory (the last path character is “`/`”), the contents of `dataToWrite` are ignored, but if the parameter value is not `NULL`—and all intermediate directories along the path do already exist—a new directory is created  (otherwise it is not).

If `url` uses an http scheme, an http `PUT` request is sent to the resource with `propertiesToWrite` as the header fields and `dataToWrite` as the data.

---

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)