Re: Subclassing NSMutableDictionary
Re: Subclassing NSMutableDictionary
- Subject: Re: Subclassing NSMutableDictionary
- From: Shawn Erickson <email@hidden>
- Date: Tue, 29 Nov 2005 10:23:23 -0800
On 11/29/05, David Alter <email@hidden> wrote:
> - (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;
> }
Anyway just for completeness try the following (written in email so
not tested/compiled)...
- (id)init
{
self = [super init];
if (self != nil) {
[self setObject:[[NSMutableArray alloc] init] forKey:@"children"];
}
return self;
}
Also looking at the code again I recommend against subclassing things
just to add members to it. Instead consider possibly adding a category
against NSMutableDictionary that implements a class method that
constructs a mutable dictionary with your mutable array keyed by
children or put that code in some controller as suggested by Idiot =P.
_______________________________________________
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