<!--
{
  "availability" : [
    "macOS: 10.3.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WebPreferences/init(identifier:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(cs)WebPreferences(im)initWithIdentifier:"
  },
  "title" : "init(identifier:)"
}
-->

# init(identifier:)

Returns an initialized `WebPreferences` object, creating one if it does not exist.

```
init!(identifier anIdentifier: String!)
```

## Parameters

`anIdentifier`

A unique identifier for the [`WebPreferences`](/documentation/WebKit/WebPreferences) object

## Return Value

A newly initialized [`WebPreferences`](/documentation/WebKit/WebPreferences) object with the identifier; if an existing `WebPreferences` object with that identifier exists, it is returned instead.

## Discussion

The `anIdentifier` argument should be unique—it is prepended to the keys used to store the receiver’s attributes in the user defaults database. [`WebView`](/documentation/WebKit/WebView-swift.class) objects can share a [`WebPreferences`](/documentation/WebKit/WebPreferences) object by using the same preferences identifier.

Typically, you do not invoke this method directly. Instead, you set the preferences identifier by sending a [`preferencesIdentifier`](/documentation/WebKit/WebView-swift.class/preferencesIdentifier) message to your WebView object. This method is the designated initializer for the WebPreferences class.

## See Also

[`identifier`](/documentation/WebKit/WebPreferences/identifier)

The receiver’s identifier.



---

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)