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

# NSTemporaryDirectory()

Returns the path of the temporary directory for the current user.

```
func NSTemporaryDirectory() -> String
```

## Return Value

A string containing the path of the temporary directory for the current user.

## Discussion

See the [`FileManager`](/documentation/Foundation/FileManager) method [`url(for:in:appropriateFor:create:)`](/documentation/Foundation/FileManager/url(for:in:appropriateFor:create:)) for the preferred means of finding the correct temporary directory.

For more information about temporary files, see [File System Programming Guide](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40010672).

## See Also

[`NSSearchPathForDirectoriesInDomains(_:_:_:)`](/documentation/Foundation/NSSearchPathForDirectoriesInDomains(_:_:_:))

Creates a list of directory search paths.



---

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)