• 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: Subject: Re: Category vs Subclass
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subject: Re: Category vs Subclass


  • Subject: Re: Subject: Re: Category vs Subclass
  • From: Ondra Cada <email@hidden>
  • Date: Fri, 17 Aug 2001 10:43:53 +0200

James,

>>>>>> James Brasure (JB) wrote at Thu, 16 Aug 2001 16:37:10 -0600:
JB> All this talk about categories vs. subclassing got me thinking. What is
JB> the advantage of using categories rather than subclassing? (I'm kind of
JB> new to Cocoa).

Well, using a category you get, I guess, three main advantages:

- the code is usually much simpler (more easy to write, debug, maintain, and
upgrade);
- it supports new services for *already* existing objects, like

@interface NSString (MyGreatExtensions)
-mySuperbNSStringAddition;
@end

... normal code ...
NSWindow *someWindow...

[[someWindow title] mySuperbNSStringAddition]

With a subclass, you would need to convert the string (unless you poseAsClass: it).

- it works without extra care for class clusters.
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc


  • Prev by Date: Re: [OT] default web browser
  • Next by Date: Re: Online C++ resources?
  • Previous by thread: Re: Subject: Re: Category vs Subclass
  • Next by thread: Fwd: Undelivered Mail Returned to Sender
  • Index(es):
    • Date
    • Thread