Subclassing NSMutableDictionary
Subclassing NSMutableDictionary
- Subject: Subclassing NSMutableDictionary
- From: David Alter <email@hidden>
- Date: Tue, 29 Nov 2005 09:59:09 -0800
I'm sure I'm missing something basic here but it is not hitting me. I
want to subclass NSMutableDictionary. My init method wants to
populate this dictionary with some data. But my sub class does not
like it when I do this.
Here is the runtime error I'm getting. It does not make sense to me.
I thought the point of subclassing was so I did not need to recreate
methods that are in the super class. That appears to be what it is
telling me to do.
2005-11-29 09:09:30.800 SubclassDict[2506] An uncaught exception was
raised
2005-11-29 09:09:30.801 SubclassDict[2506] *** -setObject:forKey:
only defined for abstract class. Define -[MyDictionary
setObject:forKey:]!
2005-11-29 09:09:30.801 SubclassDict[2506] *** Uncaught exception:
<NSInvalidArgumentException> *** -setObject:forKey: only defined for
abstract class. Define -[MyDictionary setObject:forKey:]!
Here is the code
// *************************** MyDictionary.m file
*************************************
#import "MyDictionary.h"
@implementation MyDictionary
- (id)init
{
[super init];
NSMutableArray * children = [[NSMutableArray alloc] init];
[super setObject:children forKey:@"children"]; // I also tried doing
this using "self" and not "super". It resulted in the same error
return self;
}
@end
// *************************** MyDictionary.h file
*************************************
#import <Cocoa/Cocoa.h>
@interface MyDictionary : NSMutableDictionary {
}
- (id) init;
@end
Thanks in advance for the help.
enjoy
-dave
_______________________________________________
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