• 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 NSTableView question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple NSTableView question


  • Subject: Re: Multiple NSTableView question
  • From: "David P. Henderson" <email@hidden>
  • Date: Thu, 21 Jun 2001 10:58:04 -0400

On Thursday, June 21, 2001, at 09:24 , Phillip Mills wrote:

> Being new to Obj-C and Cocoa....
>
> This seems very non-OOP and I wonder whether it's a normal Obj-C
> idiom. (?)
> I would have expected something like:
>
> - (int)numberOfRowsInTableView:(NSTableView *)theTableView
> {
> [theTableView doSpecialStuff];
> [self doCommonStuff];
> }
>
> But this, of course, requires extensions to NSTableView...sub-class,
> category...? Using PowerPlant, I would have automatically considered
> sub-classing (because it's really easy) if doSpecialStuff was at all
> complex. Is polymorphism for UI classes abnormal here?
>
Why? At some point you still have to make the determination of with
which table view you are working. And using a subclass to do so is
complete overkill, better to use conditional testing to make the
determination. If you don't like doing raw pointer comparison then use:

if ([theTableView isEqual:myFirstTable])
...

Subclassing in ObjC is even easier but generally not required as in C++.
And the majority of subclasses in Cocoa apps are subclasses of NSObject.
Also if you do need specialized behavior in a Cocoa (obj-c) class but
don't need to add any data members (ivars), categories are a better way
to go than subclassing.

Dave
--
Chaos Assembly Werks
"Imagination is more important than knowledge."
- Albert Einstein


  • Follow-Ups:
    • Re: Multiple NSTableView question
      • From: Phillip Mills <email@hidden>
References: 
 >Re: Multiple NSTableView question (From: Phillip Mills <email@hidden>)

  • Prev by Date: Re: WWDC Dev Tools / Software update
  • Next by Date: Limiting visible files in File->Open
  • Previous by thread: Re: Multiple NSTableView question
  • Next by thread: Re: Multiple NSTableView question
  • Index(es):
    • Date
    • Thread