---
title: NSUserName()
framework: foundation
role: symbol
role_heading: Function
path: foundation/nsusername()
---

# NSUserName()

Returns the logon name of the current user.

## Declaration

```swift
func NSUserName() -> String
```

## Return Value

Return Value The logon name of the current user.

## See Also

### Accessing user directories

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