init(suiteName:)
Creates a new defaults object and initializes it with the settings from the specified database.
Declaration
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 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 Preferences Utilities.
Equivalent statements using NSUserDefaults and CFPreferences APIs
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 App Sandbox and you don’t have the proper entitlements.