Re: Multiple Inheritance
Re: Multiple Inheritance
- Subject: Re: Multiple Inheritance
- From: "John C. Randolph" <email@hidden>
- Date: Tue, 1 Jan 2002 12:40:35 -0800
On Tuesday, January 1, 2002, at 10:11 AM, Gerriet M. Denkmann wrote:
>
I have learned that multiple inheritance in ObjectiveC is not
>
necessary.
>
>
I have two classes: MyCell and MyButtonCell. (Subclassed in the
>
obvious way).
>
And there are several methods which are identical for both classes.
>
>
One - not very elegant - way would be to copy & paste the code
>
for the identical methods.
>
>
But surely there is a better way ?
If you have code that you want in more than one class, the
typical way to do this is to put the code into the common
ancestor of those classes.
So, if MyCell derives from NSCell, and MyButtonCell derives from
NSButtonCell, the nearest common ancestor of those classes is
NSCell.
@interface NSCell (MyCommonCellMethods)
- etc;
@end
-jcr
"These kids today don't know the simple joy of saving four bytes
of page-0 memory on a 6502" - unknown