Contents

NSPreferencePane

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

Declaration

class NSPreferencePane

Overview

Preference panes are subclasses of 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 in File System Programming Guide 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(), 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 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:) method.

Topics

Initializing the Preference Pane

Loading the Main View

Getting the Bundle Information

Selecting and Deselecting the Preference Pane

Handling keyboard focus

Help Menu support