<!--
{
  "availability" : [
    "iOS: 2.0.0 - 7.0.0",
    "iPadOS: 2.0.0 - 7.0.0",
    "tvOS: 9.0.0 - 9.0.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 2.0.0 - 2.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/UserDefaults/init(user:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSUserDefaults(im)initWithUser:"
  },
  "title" : "init(user:)"
}
-->

# init(user:)

Creates a user defaults object initialized with the defaults for the specified user account.

```
convenience init?(user username: String)
```

## Parameters

`username`

The name of the user account.

## Return Value

An initialized [`UserDefaults`](/documentation/Foundation/UserDefaults) object whose argument and registration domains are already set up. If the current user does not have access to the specified user account, this method returns `nil`.

## Discussion

This method doesn’t put anything in the search list. Invoke it only if you’ve allocated your own [`UserDefaults`](/documentation/Foundation/UserDefaults) instance instead of using the shared one.

You do not normally use this method to initialize an instance of [`UserDefaults`](/documentation/Foundation/UserDefaults). Applications used by a superuser might use this method to update the defaults databases for a number of users. The user who started the application must have appropriate access (read, write, or both) to the defaults database of the new user, or this method returns `nil`.

### Special Considerations

This method was never implemented to do anything except return the defaults for the current user.

## See Also

[`standardUserDefaults`](/documentation/Foundation/UserDefaults/standard)

The shared defaults object for the current app.



---

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)