Re: Subclassing a NSMutableArray
Re: Subclassing a NSMutableArray
- Subject: Re: Subclassing a NSMutableArray
- From: glenn andreas <email@hidden>
- Date: Thu, 16 Mar 2006 10:24:27 -0600
On Mar 16, 2006, at 9:57 AM, Lorenzo wrote:
But subclassing an anbstarct class like NSMutableArray seems to be
impossible. Is it true?
I get this
exception: *** -count only defined for abstract class. Define
-[XYCustomArray count]!
What do you suggest?
Just use a category to extend NS(Mutable)Array to add your routine -
no need to subclass at all (not only does subclassing a class cluster
get tricky to do right, you rarely want to be doing that anyway).
@interface NSArray(SetParam)
- (void)setParam:(int)par to:(float)newValue verbose:(BOOL)verbose;
@end
@implementation NSArray(SetParam)
- (void)setParam:(int)par to:(float)newValue verbose:(BOOL)verbose
{
int i, totObjects = [self count];
for(i = 0; i < totObjects; i++){
id item = [self objectAtIndex:i];
[item setParam:par to:newValue verbose:verbose];
}
}
@end
Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | build, mutate, evolve | images, textures, backgrounds, art
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden