• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Multiple Inheritance
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Multiple Inheritance (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: Multiple Inheritance
  • Next by Date: Re: Translating filenames for command line?
  • Previous by thread: Re: Multiple Inheritance
  • Next by thread: A good read on newbie questions
  • Index(es):
    • Date
    • Thread