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

# loadMainView()

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

```
func loadMainView() -> NSView
```

## Discussion

The default implementation loads the main nib file (identified by [`mainNibName`](/documentation/PreferencePanes/NSPreferencePane/mainNibName)) and calls [`assignMainView()`](/documentation/PreferencePanes/NSPreferencePane/assignMainView()) to set the main view of the preference pane. Returns the main view if successful, or `nil` otherwise.

Subclasses should rarely need to override this method. Override this method if you need to use a non-nib based technique for creating the main view. Call [`NSPreferencePane`](/documentation/PreferencePanes/NSPreferencePane) to set the main view of the preference pane before returning. Also call [`NSPreferencePane`](/documentation/PreferencePanes/NSPreferencePane), [`NSPreferencePane`](/documentation/PreferencePanes/NSPreferencePane), and [`NSPreferencePane`](/documentation/PreferencePanes/NSPreferencePane) to set the initial, first, and last keyboard focus views, respectively.

---

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)