Subclassing NSDictionary...
Subclassing NSDictionary...
- Subject: Subclassing NSDictionary...
- From: Alec Carlson <email@hidden>
- Date: Fri, 26 Apr 2002 16:37:27 -0500
Hopefully, this will be a quick answer by someone. I am trying to subclass
NSMutableDictionary as follows:
@interface foo : NSMutableDictionary {
}
-(id) init;
-(void) setSomeValue:(NSString *)theValue;
@end
and implement it as follows:
@implementation foo
-(id) init
{
self = [super init];
return self;
}
- (void) setSomeValue:(NSString *)theString
{
[self setObject:theString forKey:@"key"];
}
@end
I instantiate the object and test it as follows:
{
foo *test = [[foo alloc] init];
[foo setSomeValue:3];
}
When I execute the [foo setSomeValue:3] line, I get:
2002-04-26 16:28:36.847 TestServer[2797] An uncaught exception was raised
2002-04-26 16:28:36.848 TestServer[2797] *** -setObject:forKey: only defined
for abstract class. Define -[foo setObject:forKey:]!
I tried adding
- (void) setObject:(id)anObject forKey:(id)aKey;
to foo's methods and implement it as follows:
- (void) setObject:(id)anObject forKey:(id)aKey
{
[super setObject:anObject forKey:aKey];
}
but this produces the same exception. If I change super to self, it calls
itself recursively.
I know enough about obj-c to be dangerous. I'm sure there is a simple
answer. Some help would be appreciated.
Thanx -
Alec
-----------------------------------------------------------------------
Time is Short, and the Water Rises
-----------------------------------------------------------------------
_______________________________________________
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.