• 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: Stumped on memory problem :(
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stumped on memory problem :(


  • Subject: Re: Stumped on memory problem :(
  • From: Rob Keniger <email@hidden>
  • Date: Tue, 6 Jan 2009 17:16:12 +1000


On 02/01/2009, at 11:14 AM, Jacob Rhoden wrote:

   NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
   [dict setValue: @"" forKey: [NSString stringWithString:@"one"]];
   [dict setValue: @"" forKey: [NSString stringWithString:@"two"]];

   NSMutableArray *array = [[NSMutableArray array] init];
   NSEnumerator* keyEnum = [dict keyEnumerator];



The problem is this line:

NSMutableArray *array = [[NSMutableArray array] init];

This should be either [[NSMutableArray alloc] init] with an - autorelease before you leave the scope of the method, or

[NSMutableArray array] which returns an autoreleased object and does need its own -autorelease method.

By the way, you don't need to do [NSString stringWithString:@"one"], you can just use the string literal @"one" directly.

--
Rob Keniger



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Stumped on memory problem :( (From: Jacob Rhoden <email@hidden>)

  • Prev by Date: Re: Stumped on memory problem :(
  • Next by Date: Re: Stumped on memory problem :(
  • Previous by thread: Re: Stumped on memory problem :(
  • Next by thread: Re: Stumped on memory problem :(
  • Index(es):
    • Date
    • Thread