Re: count only defined for abstract class error
Re: count only defined for abstract class error
- Subject: Re: count only defined for abstract class error
- From: Francisco Tolmasky <email@hidden>
- Date: Thu, 1 May 2003 19:49:05 -0700
The reason that this isn't working is that NSMutableArray is actually
an Abstract Data Type since Apple uses distributed objects. What you
need to do is the following:
@class MutableArraySubclass: NSMutableArray
{
NSMutableArray *embedded;
}
- (unsigned)count;
@end
@implementation MutableArraySubclass
- (unsigned)count
{
return [embedded count];
}
- (void)dealloc
{
[embedded release];
[super dealloc];
}
@end;
I don't know if the following will work, just though of it now, but if
you don't want to go crazy writing [embedded ____] for every function,
try implementing these in your MutableArraySubclass:
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
{
if ([super respondsToSelector: aSelector])
return [self methodSignatureForSelector: aSelector];
else return [embedded methodSignatureForSelector: aSelector];
}
- (void)forwardInvocation:(NSInvocation *)anInvocation
{
if([embedded respondsToSelector: [anInvocation selector]])
[anInvocation invokeWithTarget: embedded];
else [self doesNotRecognizeSelector: [anInvocation selector]];
}
I'm almost certain that mehtodSignatureForSelector in this case is
miswritten, but play around with it a bit. Worst comes to worst, just
take the 10 minutes to rewrite all the NSMutableArray functions you
want (for exmaple: -(id)objectAtIndex:(unsigned)anIndex { return
[embedded objectAtIndex: anIndex]; } )
On Thursday, May 1, 2003, at 05:30 PM,
email@hidden wrote:
>
count
Francisco Tolmasky
email@hidden
http://users.adelphia.net/~ftolmasky
_______________________________________________
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.