I am newbie in Cocoa Application.
I want to programmatically open my application's preferences window
By googling, I can just found --> [[NSWorkspace sharedWorkspace] openFile:@"MyApp.prefPane"];"
Any help would be appreciated.---
Thanks.
You open the preference window just like any other within your app:
In App Delegate class:
- (IBAction)showPreferencePanel:(id)sender {
if (!_preferenceController)
_preferenceController = [[PreferenceController alloc] init];
[_preferenceController showWindow:self];
}
Where PreferenceController
is:
@interface PreferenceController : NSWindowController <NSWindowDelegate, NSToolbarDelegate, FontChooserViewDelegate>
...
@end
And in MainMenu.xib
the showPreferencePanel
method is hooked in like this: