<!--
{
  "availability" : [
    "macCatalyst: 14.0.0 -",
    "macOS: 10.1.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PreferencePanes",
  "identifier" : "/documentation/PreferencePanes/NSPreferencePane",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Preference Panes"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPreferencePane"
  },
  "title" : "NSPreferencePane"
}
-->

# NSPreferencePane

The interface for providing preference panes to System Preferences or other apps.

```
class NSPreferencePane
```

## Overview

Preference panes are subclasses of [`NSPreferencePane`](/documentation/PreferencePanes/NSPreferencePane), packaged up in bundles and loaded by a preference application, such as System Preferences. These bundles have a suffix of `.prefPane`. Bundles intended for use by System Preferences are located in the `Library/PreferencePanes` directories of the various file system domains. See the chapter [About the macOS File System](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW14) in [File System Programming Guide](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40010672) for information about domains.

The preference pane bundle normally contains a nib file with the user interface for modifying user preferences. The nib file contains a window assigned to the _window outlet of the preference pane instance (the nib’s File’s Owner). The `NSPreferencePane` implementation of [`loadMainView()`](/documentation/PreferencePanes/NSPreferencePane/loadMainView()), invoked by the preference application, loads the nib file and uses the content view of _window as the preference pane’s main view. Override this method if you need a different technique for creating the user interface.

The [`NSPreferencePane`](/documentation/PreferencePanes/NSPreferencePane) subclass is responsible for initializing the user interface with the current preference settings and recording any modifications the user makes. Through a series of `will...`, `did...`, and `should...` methods, the preference application notifies the preference pane when the pane is selected (displayed) and deselected, allowing the pane to perform the necessary actions at the appropriate times. Implement these methods (and any additional target-action methods connected to the interface) as needed to produce the desired behavior for your preference pane.

Preference panes support Help menu items. Specify global help menu items in your bundle’s `Info.plist` file under the `NSPrefPaneHelpAnchors` key. To add dynamic help items, implement the [`updateHelpMenu(with:)`](/documentation/PreferencePanes/NSPreferencePane/updateHelpMenu(with:)) method.

## Topics

### Initializing the Preference Pane

[`init(bundle:)`](/documentation/PreferencePanes/NSPreferencePane/init(bundle:))

Initializes a preference pane with the specified bundle.

### Loading the Main View

[`loadMainView()`](/documentation/PreferencePanes/NSPreferencePane/loadMainView())

Loads the preference pane’s user interface into its main view.

[`assignMainView()`](/documentation/PreferencePanes/NSPreferencePane/assignMainView())

Locates and assigns the preference pane’s main view from the nib file loaded by [`loadMainView()`](/documentation/PreferencePanes/NSPreferencePane/loadMainView()).

[`mainViewDidLoad()`](/documentation/PreferencePanes/NSPreferencePane/mainViewDidLoad())

Notifies the preference pane that the main view is set up and prepared to be displayed.

### Getting the Bundle Information

[`bundle`](/documentation/PreferencePanes/NSPreferencePane/bundle)

The preference pane’s bundle.

[`mainNibName`](/documentation/PreferencePanes/NSPreferencePane/mainNibName)

The name of the preference pane’s nib file.

[`mainView`](/documentation/PreferencePanes/NSPreferencePane/mainView)

The main view of the preference pane.

### Selecting and Deselecting the Preference Pane

[`willSelect()`](/documentation/PreferencePanes/NSPreferencePane/willSelect())

Notifies the preference pane that the main app is about to display the preference pane’s main view.

[`didSelect()`](/documentation/PreferencePanes/NSPreferencePane/didSelect())

Notifies the preference pane that the main app has just displayed the preference pane’s main view.

[`willUnselect()`](/documentation/PreferencePanes/NSPreferencePane/willUnselect())

Notifies the preference pane that the main app is about to stop displaying the preference pane’s main view.

[`didUnselect()`](/documentation/PreferencePanes/NSPreferencePane/didUnselect())

Notifies the preference pane that the main app has just stopped displaying the preference pane’s main view.

[`isSelected`](/documentation/PreferencePanes/NSPreferencePane/isSelected)

A Boolean value that indicates whether the preference pane is currently selected.

[`shouldUnselect`](/documentation/PreferencePanes/NSPreferencePane/shouldUnselect)

A Boolean value that indicates whether the preference pane is able to be deselected.

[`NSPreferencePaneUnselectReply`](/documentation/PreferencePanes/NSPreferencePaneUnselectReply)

Constants that indicate the preference pane’s availability to be deselected.

[`reply(toShouldUnselect:)`](/documentation/PreferencePanes/NSPreferencePane/reply(toShouldUnselect:))

Notifies the main application of the preference pane’s ability to be deselected.

### Handling keyboard focus

[`firstKeyView`](/documentation/PreferencePanes/NSPreferencePane/firstKeyView)

The first view in the keyboard focus chain.

[`initialKeyView`](/documentation/PreferencePanes/NSPreferencePane/initialKeyView)

The view that should have keyboard focus when the pane is selected.

[`lastKeyView`](/documentation/PreferencePanes/NSPreferencePane/lastKeyView)

The last view in the keyboard focus chain.

[`autoSaveTextFields`](/documentation/PreferencePanes/NSPreferencePane/autoSaveTextFields)

A Boolean value that indicates whether text fields save their values before changing preference panes.

### Help Menu support

[`updateHelpMenu(with:)`](/documentation/PreferencePanes/NSPreferencePane/updateHelpMenu(with:))

Updates the help menu.



---

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)