Cocoa:Cocoa Action Categories for Interface Builder (Multiple Inheritance)
So now we've got a fairly general method of doing multiple inheritance within Cocoa applications. Now for some fun stuff. Wouldn't it be great if we could define categories of IB Actions on NSWindow as protocols, and then make it real easy to wire them up using the connection logic of Interface Builder.
As it turns out, this was way easier to do than I thought. Interface Builder is able to read Objective-C header files to find classnames, outlets and actions, but the parser is very easy to fool. All we have to do is wrap our 'action declarations' from our NSWindow category with a preprocessor exclude:
/* never compiled, but parsed by IB just fine*/
/* the great part about actions is their function signature will not be changing!*/
And Interface Builder will parse out the action definitions and allow you to wire connections to them. But the trick is, you don't need to implement the actions - the category methods on NSWindow will take care of that for you.
REMEMBER: if you use this technique of adding actions to NSWindow using a category/protocol, be sure that your ACTION NAMES are VERBOSE, so as to distinguish them from any additions the Cocoa team might make to NSWindow in the future. You have been warned!