<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FileManager/urls(for:in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileManager(im)URLsForDirectory:inDomains:"
  },
  "title" : "urls(for:in:)"
}
-->

# urls(for:in:)

Returns an array of URLs for the specified common directory in the requested domains.

```
func urls(for directory: FileManager.SearchPathDirectory, in domainMask: FileManager.SearchPathDomainMask) -> [URL]
```

## Parameters

`directory`

The search path directory. The supported values are described in [`FileManager.SearchPathDirectory`](/documentation/Foundation/FileManager/SearchPathDirectory).

`domainMask`

The file system domain to search. The value for this parameter is one or more of the constants described in [`FileManager.SearchPathDomainMask`](/documentation/Foundation/FileManager/SearchPathDomainMask).

## Return Value

An array of [`NSURL`](/documentation/Foundation/NSURL) objects identifying the requested directories. The directories are ordered according to the order of the domain mask constants, with items in the user domain first and items in the system domain last.

## Discussion

This method is intended to locate known and common directories in the system. For example, setting the directory to [`FileManager.SearchPathDirectory.applicationDirectory`](/documentation/Foundation/FileManager/SearchPathDirectory/applicationDirectory), will return the Applications directories in the requested domain. There are a number of common directories available in the [`FileManager.SearchPathDirectory`](/documentation/Foundation/FileManager/SearchPathDirectory), including: [`FileManager.SearchPathDirectory.desktopDirectory`](/documentation/Foundation/FileManager/SearchPathDirectory/desktopDirectory), [`FileManager.SearchPathDirectory.applicationSupportDirectory`](/documentation/Foundation/FileManager/SearchPathDirectory/applicationSupportDirectory), and many more.

---

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)