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

# init(suiteName:)

Creates a new defaults object and initializes it with the settings from the specified database.

```
init?(suiteName suitename: String?)
```

## Parameters

`suitename`

The name of the app group or suite to add to the search list. To read
and write settings for a shared app group, specify the app group identifier. Don’t
specify the [`globalDomain`](/documentation/Foundation/UserDefaults/globalDomain) or your app’s bundle identifier. If you specify `nil`,
this method returns a defaults object that reads and writes from the current app’s settings.

## Discussion

Use this method to create a defaults object that reads settings from the custom
domain you specify. For example, you might use this method to access settings you
share among multiple apps or between your app and an app extension. The returned object
writes settings to the domain you specified. Every instance of ``UserDefaults shares the
contents of the argument and registration domains.

The `suiteName` parameter matches the domain parameter of the corresponding CFPreferences APIs, except
when translating between Foundation and Core Foundation constants. The following example shows
two equivalent statements. For more details, see <doc://com.apple.documentation/documentation/CoreFoundation/preferences-utilities>.

Equivalent statements using NSUserDefaults and CFPreferences APIs

```swift
let userDefaultsValue = UserDefaults(suiteName: "someDomain")?.object(forKey: "someKey")
let preferencesValue = CFPreferencesCopyAppValue("someKey" as CFString, "someDomain" as CFString)
// userDefaultsValue and preferencesValue are equal
```

In macOS, specify another app’s bundle identifier to search that app’s settings. You
can’t search another app’s settings if either app runs in an
<doc://com.apple.documentation/documentation/Security/app-sandbox> and you don’t have
the proper entitlements.

---

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)