Re: Subclassing NSMutableDictionary
Re: Subclassing NSMutableDictionary
- Subject: Re: Subclassing NSMutableDictionary
- From: Guy English <email@hidden>
- Date: Tue, 29 Nov 2005 13:29:42 -0500
>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;
>}
Just a little warning: this code leaks an NSMutableArray. alloc, init gets one ref, then you add it to the dictionary which will add another ref. Either autorelease it or use a class method that'll return an an autoreleased array.
- (id)init
{
self = [super init];
if (self != nil) {
[self setObject: [NSMutableArray array] forKey:@"children"];
}
return self;
}
Take care,
Guy
_______________________________________________
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