<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSFileVersion/temporaryDirectoryURLForNewVersionOfItem(at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileVersion(cm)temporaryDirectoryURLForNewVersionOfItemAtURL:"
  },
  "title" : "temporaryDirectoryURLForNewVersionOfItem(at:)"
}
-->

# temporaryDirectoryURLForNewVersionOfItem(at:)

Creates and returns a temporary directory to use for saving the contents of the file.

```
class func temporaryDirectoryURLForNewVersionOfItem(at url: URL) -> URL
```

## Parameters

`url`

The URL of the file whose contents you want to save.

## Return Value

A URL identifying the temporary directory in which to create a the new file. You must delete the directory specified by this URL after you have created the file and moved it to its proper location.

## Discussion

You can use this method in situations where you want to create a file in a temporary location. For example, you might use this method when saving the contents of a file to disk for the first time. When you finish creating the temporary file, move it to a more appropriate location, such as the user’s `Documents` directory. You must delete the directory returned by this method when you are done with it.

---

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)