---
title: "temporaryDirectoryURLForNewVersionOfItem(at:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nsfileversion/temporarydirectoryurlfornewversionofitem(at:)"
---

# temporaryDirectoryURLForNewVersionOfItem(at:)

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

## Declaration

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

## Parameters

- `url`: The URL of the file whose contents you want to save.

## Return Value

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

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.

## See Also

### Getting the Version of a File

- [currentVersionOfItem(at:)](foundation/nsfileversion/currentversionofitem(at:).md)
- [otherVersionsOfItem(at:)](foundation/nsfileversion/otherversionsofitem(at:).md)
- [version(itemAt:forPersistentIdentifier:)](foundation/nsfileversion/version(itemat:forpersistentidentifier:).md)
