---
title: "NSHomeDirectoryForUser(_:)"
framework: foundation
role: symbol
role_heading: Function
path: "foundation/nshomedirectoryforuser(_:)"
---

# NSHomeDirectoryForUser(_:)

Returns the path to a given user’s home directory.

## Declaration

```swift
func NSHomeDirectoryForUser(_ userName: String?) -> String?
```

## Parameters

- `userName`: The name of a user.

## Return Value

Return Value The path to the home directory for the user specified by userName.

## Discussion

Discussion For more information on file system utilities, see Low-Level File Management Programming Topics.

## See Also

### Accessing user directories

- [homeDirectoryForCurrentUser](foundation/filemanager/homedirectoryforcurrentuser.md)
- [NSHomeDirectory()](foundation/nshomedirectory().md)
- [NSUserName()](foundation/nsusername().md)
- [NSFullUserName()](foundation/nsfullusername().md)
- [homeDirectory(forUser:)](foundation/filemanager/homedirectory(foruser:).md)
- [temporaryDirectory](foundation/filemanager/temporarydirectory.md)
- [NSTemporaryDirectory()](foundation/nstemporarydirectory().md)
