---
title: "homeDirectory(forUser:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/filemanager/homedirectory(foruser:)"
---

# homeDirectory(forUser:)

Returns the home directory for the specified user.

## Declaration

```swift
func homeDirectory(forUser userName: String) -> URL?
```

## Parameters

- `userName`: The username of the owner of the desired home directory.

## Return Value

Return Value A URL object containing the location of the specified user’s home directory, or nil if no such user exists or the user’s home directory is not available.

## See Also

### Accessing user directories

- [homeDirectoryForCurrentUser](foundation/filemanager/homedirectoryforcurrentuser.md)
- [NSHomeDirectory()](foundation/nshomedirectory().md)
- [NSUserName()](foundation/nsusername().md)
- [NSFullUserName()](foundation/nsfullusername().md)
- [NSHomeDirectoryForUser(_:)](foundation/nshomedirectoryforuser(_:).md)
- [temporaryDirectory](foundation/filemanager/temporarydirectory.md)
- [NSTemporaryDirectory()](foundation/nstemporarydirectory().md)
