---
title: "NSSearchPathForDirectoriesInDomains(_:_:_:)"
framework: foundation
role: symbol
role_heading: Function
path: "foundation/nssearchpathfordirectoriesindomains(_:_:_:)"
---

# NSSearchPathForDirectoriesInDomains(_:_:_:)

Creates a list of directory search paths.

## Declaration

```swift
func NSSearchPathForDirectoriesInDomains(_ directory: FileManager.SearchPathDirectory, _ domainMask: FileManager.SearchPathDomainMask, _ expandTilde: Bool) -> [String]
```

## Discussion

Discussion Creates a list of path strings for the specified directories in the specified domains. The list is in the order in which you should search the directories. If expandTilde is true, tildes are expanded as described in expandingTildeInPath. You should consider using the FileManager methods urls(for:in:) and url(for:in:appropriateFor:create:). which return URLs, which are the preferred format. For more information on file system utilities, see File System Programming Guide. note: The directory returned by this method may not exist. This method simply gives you the appropriate location for the requested directory. Depending on the application’s needs, it may be up to the developer to create the appropriate directory and any in between.

## See Also

### Locating system directories

- [url(for:in:appropriateFor:create:)](foundation/filemanager/url(for:in:appropriatefor:create:).md)
- [urls(for:in:)](foundation/filemanager/urls(for:in:).md)
- [NSOpenStepRootDirectory()](foundation/nsopensteprootdirectory().md)
