"Multiple Inheritance" between NSTableView and NSOutlineView
"Multiple Inheritance" between NSTableView and NSOutlineView
- Subject: "Multiple Inheritance" between NSTableView and NSOutlineView
- From: Jerry Krinock <email@hidden>
- Date: Mon, 03 Jul 2006 19:26:54 -0700
- Thread-topic: "Multiple Inheritance" between NSTableView and NSOutlineView
I have in my app:
XXTableView, a subclass of NSTableView
XXOutlineView, a subclass of NSOutlineView.
I just wrote a group of methods, with identical implementations that I would
like to add to both XXTableView and XXOutlineView, without duplicating them.
It seems there should be a way to do this, but I can't see it.
A category? No, because categories can only be added to one class.
A protocol? No, because protocols are only interfaces, not implementations.
A superclass? No, because XXTableView and XXOutlineView already have
different superclasses, and Objective-C does not do multiple inheritance.
Now, I understand that NSOutlineView is a subclass of NSTableView, and
theoretically I should be able to combine all my XXTableView into
XXOutlineView, and then of course all my common methods could go there too.
This would be difficult enough just given the differences between my
XXTableView and XXOutlineView. But then I'd also have to implement the
outline dataSource methods for my table so that this outline would somehow
degenerate into a table. For example, isItemExpandable: would always return
NO. And I'm afraid this would be a real mess. Then there are all those
"analagous" delegate methods between NSTableView and NSOutlineView...I think
that Apple bent the rules a little in calling NSOutlineView a subclass of
NSTableView.
Is this combined superclass do-able? Or is there some other feature of
Objective-C I have overlooked that could put these common method
implementations into both of my existing subclasses?
Jerry Krinock
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden