Software:
News ToolsReg Shops |
The Register » Software » A better way to build OS X preferencesBehind the interfacePublished Tuesday 11th March 2008 06:02 GMT To use these classes, you’ll first need to get the corresponding header files Create a new, empty Cocoa application to serve as a test bed for this stuff. You’ll typically want to invoke the preferences window in response to a menu option, but in my test application, I just used a button press in the main window. Here’s what the action procedure (inside
- (IBAction) showPreferences: (id) sender
{
[NSPreferences setDefaultPreferencesClass: [AppPreferences class]];
[[NSPreferences sharedPreferences] showPreferencesPanel];
}
Here, we’ve set up a subclass of
- (id) init
{
_nsBeginNSPSupport(); // MUST come before [super init]
[super init];
[self addPreferenceNamed: @"General"
owner: [GeneralPreferences sharedInstance]];
[self addPreferenceNamed: @"HotKeys"
owner: [HotKeyPreferences sharedInstance]];
return self;
}
- (BOOL) usesButtons
{
return NO;
}
In this case, the Two points: first, in real-world code you’d typically localize the page names, “General” and “HotKeys” in this case. Second, by default, You’ll also note that evil-looking call to A very simple demo project can be downloaded here. There’s more that can be said about Until next time, have fun! ® 17 comments posted — Comment period finished Thank you!Posted: 08:56 11th March 2008 OK for some but not others?Posted: 14:17 11th March 2008 The rant area is down the hall...Posted: 16:19 11th March 2008 Re: OK for some but not others?Posted: 16:47 11th March 2008 Apple is just as guilty of AC behavior as the next guyPosted: 17:21 11th March 2008
Track this type of story as a custom Atom/RSS feed or by email.
|
|
||||||||
Top 20 stories • All The Week’s Headlines • Archive • Search