• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Subclassing NSMutableDictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Subclassing NSMutableDictionary
      • From: Shawn Erickson <email@hidden>
References: 
 >Subclassing NSMutableDictionary (From: David Alter <email@hidden>)
 >Re: Subclassing NSMutableDictionary (From: Shawn Erickson <email@hidden>)

  • Prev by Date: Re: Subclassing NSMutableDictionary
  • Next by Date: Re: Is Apple's singleton sample code correct?
  • Previous by thread: Re: Subclassing NSMutableDictionary
  • Next by thread: Re: Subclassing NSMutableDictionary
  • Index(es):
    • Date
    • Thread