subclassing NSMutableArray
subclassing NSMutableArray
- Subject: subclassing NSMutableArray
- From: brian lee dae yung <email@hidden>
- Date: Thu, 1 Aug 2002 08:42:26 -0700 (PDT)
Hello, i am having difficulties subclassing the NSMutableArray class.
I keep getting the following run time error message, implying that my
init methods are not written properly:
initialization method -initWithCapacity: cannot be sent to an abstract
object of class MxPriceSeries: Create a concrete instance!
Below are some code snippets. The -initWithNam: capacity: is the new
designated initializer. -initWithCapacity: has been overridden to
reference the new designated initializer.
From MxPriceSeries.h :
#import <Cocoa/Cocoa.h>
@interface MxPriceSeries : NSMutableArray
{
NSString *name ;
}
+ (id) withName:(NSString *)n ;
- (id) init ;
- (id) initWithCapacity:(unsigned)c ;
- (id) initWithName:(NSString *)n capacity:(unsigned)c ;
@end
From MxPriceSeries.m :
+ (id) withName:(NSString *)n
{
// this produces the same error message
//return [[self alloc] initWithName:n capacity:64] ;
MxPriceSeries *ps = [self alloc] ;
return [ps initWithName:n capacity:64] ;
}
- (id) init
{ return [self initWithName:@"NONE" capacity:64] ; }
- (id) initWithCapacity:(unsigned)c
{ return [self initWithName:@"NONE" capacity:c] ; }
- (id) initWithName:(NSString *)n capacity:(unsigned)c
{
if (!(self = [super initWithCapacity:c])) return nil ;
[self name:n] ;
return self ;
}
The call that i am using is the static method:
MxPriceSeries *series = [MxPriceSeries withName: name] ;
When i use the debugger, i get some interesting results. I set a
breakpoint on the designated initializer in my class and then print the
description of self, which is:
-count only defined for abstract class. Define -[MxPriceSeries count]!
Why is an error message the description of self? And what does it mean
that -count is only defined for abstract class? NSMutableArray is not
abstract, so that is not it. I have not explicitly defined -count, but
i shouldn't have to, since it is inherited from the super class.
I've tried many variations on the code, but they all produce the same
result. Any help on this is greatly appreciated.
regards, brian rowe.
=====
.
{: }
.. the mux space conglomerate ..
" family values were never this good "
www . mux space . com
Yahoo! Health - Feel better, live better
http://health.yahoo.com
_______________________________________________
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.