• 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: Lance Bland <email@hidden>
  • Date: Tue, 1 Jan 2002 14:16:56 -0500

On Tuesday, January 1, 2002, at 01:11 PM, Gerriet M. Denkmann wrote:

I have two classes: MyCell and MyButtonCell. (Subclassed in the obvious way).

Obvious? I assume you mean NSCell -> MyCell and NSButtonCell -> MyButtonCell.

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 ?

You can:

1) Add a Category to NSCell with those methods defined in that category. (Doesn't work if the methods need additional ivars).

2) Add a delegate ivar to both MyCell and MyButtonCell and make that ivar an instance of a class that implements your common methods and forward calls to the delegate.

3) Put the method definitions in a separate file and then place an #include precompiler directive to include that file (and hence those methods) into your classes at compile time. (don't use #import)

4) Write a program to duplicate the methods for any desired class (that is what we ended up doing).

-lance
_______________________________________________
Lance Bland
System Administrator at VVI
mailto:email@hidden
http://www.vvi.com
Realtime, bulk and web data reporting and visualization


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

  • Prev by Date: Re: OOP Clarification
  • Next by Date: Re: Multiple Inheritance
  • Previous by thread: Multiple Inheritance
  • Next by thread: Re: Multiple Inheritance
  • Index(es):
    • Date
    • Thread