Re: Stumped on memory problem :(
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