---
title: "init(for:in:appropriateFor:create:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/url/init(for:in:appropriatefor:create:)"
---

# init(for:in:appropriateFor:create:)

Creates a file URL for a common directory in a domain.

## Declaration

```swift
init(for directory: FileManager.SearchPathDirectory, in domain: FileManager.SearchPathDomainMask, appropriateFor url: URL? = nil, create shouldCreate: Bool = false) throws
```

## Parameters

- `directory`: The search path for the commonly used directory, such as doc://com.apple.foundation/documentation/Foundation/FileManager/SearchPathDirectory/desktopDirectory or doc://com.apple.foundation/documentation/Foundation/FileManager/SearchPathDirectory/downloadsDirectory.
- `domain`: The file system domain to search, which the values in doc://com.apple.foundation/documentation/Foundation/FileManager/SearchPathDomainMask define. Specify only one domain for this parameter. You may not specify doc://com.apple.foundation/documentation/Foundation/FileManager/SearchPathDomainMask/allDomainsMask with this initializer.
- `url`: The file URL for determining the location of the returned URL. Only the volume of this parameter is relevant. The initializer ignores this parameter unless the directory parameter contains the value doc://com.apple.foundation/documentation/Foundation/FileManager/SearchPathDirectory/itemReplacementDirectory and the domain parameter contains the value doc://com.apple.foundation/documentation/Foundation/FileManager/SearchPathDomainMask/userDomainMask.
- `shouldCreate`: A Boolean value that indicates whether the initializer creates the directory if it doesn’t already exist.

## See Also

### Creating a file URL for a common directory

- [FileManager.SearchPathDirectory](foundation/filemanager/searchpathdirectory.md)
- [FileManager.SearchPathDomainMask](foundation/filemanager/searchpathdomainmask.md)
