Re: Subclassing NSArray
Re: Subclassing NSArray
- Subject: Re: Subclassing NSArray
- From: David Remahl <email@hidden>
- Date: Sun, 15 Sep 2002 15:09:20 +0200
>
I am having difficulty subclassing NSArray. The subclass does not
>
inherit NSArray's methods. For instance, if MyThing is a subclass of
>
NSArray, and A is an instance of MyThing, then [A count] produces an
>
execution error that says:
>
>
2002-09-15 08:54:39.158 ArrayTest[14121] *** Uncaught exception:
>
<NSInvalidArgumentException> *** -count only defined for abstract
>
class. Define -[MyThing count]!
>
>
From this I gather that 'count' is defined only for the NSArray
>
abstract class, and that a subclass of NSArray is expected to be a
>
concrete class that explicity implements 'count'. However, I don't want
>
to create an entire concrete class; I just want to subclass and add a
>
few methods.
>
>
Is subclassing NSArray impossible? Do I need to use categories instead?
One way is to use categories. In many cases it is sufficient.
To subclass, you need to be aware that NSArrays are class clusters.
<
http://www.cocoadev.com/index.pl?ClassClusters>
/ Rgds, David Remahl
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.