First Responder is specifically this.
What you're asking about, though, is target-action. You have a UI object (button, menu item) that you need to cause multiple things to happen, but the UI object only sends one action.
Hence the solution: Make that action do multiple things.
Hook the UI object up to an action method you implement in your controller object (in your case, the document). In that method, do all the things the button needs to cause.
The subclassing solution is basically the same thing, except instead of hooking the UI object up to your document, you hook it up to the font manager, but you also make the font manager an instance of a subclass of NSFontManager that you create, rather than an instance of NSFontManager directly. In your subclass, you override addFontTrait:
and add the other behavior in your implementation. At either the start or the end of that method, you send [super addFontTrait:sender]
to invoke NSFontManager's implementation, so the original implementation gets done.
Long paragraph, but it's not actually all that much more work: The difference is just making the subclass and making the instance an instance of that subclass.
You've said before that “the Apple Documentation is incredibly vague”, but it's really not. There just happens to be a lot of it, and maybe you haven't been looking at the right documents.
These are the documents you need to read, from start to finish, and in order:
EDIT: This list is for Xcode 3. I posted an updated (for Xcode 4) version of this list in another answer.
- The Objective-C Programming Language
- The Memory Management Programming Guide for Cocoa
- The Cocoa Fundamentals Guide (which explains target-action, among other things)
- Application Architecture Overview
- Resource Programming Guide
- Interface Builder User Guide
- The Xcode 3 guides:
- Xcode Project Management Guide
- Xcode Workspace Guide
- Xcode Build System Guide
- Xcode Debugging Guide
- Document-Based Applications Overview
There is also an Instruments User Guide, but, unfortunately, that one is vague—or, to be more precise, incomplete. It omits a lot of useful information, like how to use Instruments' Zombies template to debug crashes. It's a high-level overview, nothing more.
Also, bookmark these:
That's a lot of reading, but it'll tell you everything you need to know, and that order is roughly the order you'll need to know it in.