<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSUserDefaultsController",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSUserDefaultsController"
  },
  "title" : "NSUserDefaultsController"
}
-->

# NSUserDefaultsController

A controller that accesses user preference information for your app from the user’s defaults database.

```
class NSUserDefaultsController
```

## Overview

[`NSUserDefaultsController`](/documentation/AppKit/NSUserDefaultsController) is a Cocoa bindings–compatible controller class. Properties of the shared instance of this class can be bound to user interface elements to access and modify values stored in <doc://com.apple.documentation/documentation/Foundation/UserDefaults>.

## Topics

### Obtaining the shared instance

[`shared`](/documentation/AppKit/NSUserDefaultsController/shared)

Returns the shared instance of NSUserDefaultsController, creating it if necessary.

### Initializing a user defaults controller

[`init(defaults:initialValues:)`](/documentation/AppKit/NSUserDefaultsController/init(defaults:initialValues:))

Returns an initialized NSUserDefaultsController object using the NSUserDefaults instance specified in `defaults` and the initial default values contained in the `initialValues` dictionary.

[`init(coder:)`](/documentation/AppKit/NSUserDefaultsController/init(coder:))

### Managing user defaults values

[`defaults`](/documentation/AppKit/NSUserDefaultsController/defaults)

Returns the instance of NSUserDefaults in use by the receiver.

[`initialValues`](/documentation/AppKit/NSUserDefaultsController/initialValues)

Returns a dictionary containing the receiver’s initial default values.

[`hasUnappliedChanges`](/documentation/AppKit/NSUserDefaultsController/hasUnappliedChanges)

Returns whether the receiver has user default values that have not been saved to NSUserDefaults.

[`appliesImmediately`](/documentation/AppKit/NSUserDefaultsController/appliesImmediately)

Returns whether any changes made to bound user default properties are saved immediately.

[`values`](/documentation/AppKit/NSUserDefaultsController/values)

Returns a key value coding compliant object that is used to access the user default properties.

[`revert(_:)`](/documentation/AppKit/NSUserDefaultsController/revert(_:))

Causes the receiver to discard any unsaved changes to bound user default properties, restoring their previous values.

[`revertToInitialValues(_:)`](/documentation/AppKit/NSUserDefaultsController/revertToInitialValues(_:))

Causes the receiver to discard all edits and replace the values of all the user default properties with any corresponding values in the [`initialValues`](/documentation/AppKit/NSUserDefaultsController/initialValues) dictionary.

[`save(_:)`](/documentation/AppKit/NSUserDefaultsController/save(_:))

Saves the values of the receiver’s user default properties.



---

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)