Search code examples
objective-ccocoamacosnspreferencepane

adding preference pane to an application


I have an application which resides in menu bar, pretty much like this one
menu app

And I'm trying to create a preference pane for it, as described in the apple docs.
That guide shows how to create both prefpane plugin for System Preferences and preference window for standalone application. Yet, in the second case, it seems to be missing something.

So, I have main application class with -(IBAction) displayPreferences:(id)sender; action called when user clicks 'Preferences...' in the menu.
And I also have controller extending NSPreferencePane and connected to NSWindow object in Interface Builder (just likes docs describe).

The question is, how to connect them? I.e.,

-(IBAction) displayPreferences:(id)sender {
  // what do we write here to display preferences window?
}

Thank you!


Solution

  • If you want to have System Preferences open to your preference pane, you can create a file URL to your .prefPane bundle and then send that to -[NSWorkspace openURL:]. If you want to be really explicit about launching options, you can use -[NSWorkspace openURLs:withAppBundleIdentifier:options:additionalEventParamDescriptor:launchIdentifiers:].