Re: NSDictionary, allKeys and the NSAutoreleasePool
Re: NSDictionary, allKeys and the NSAutoreleasePool
- Subject: Re: NSDictionary, allKeys and the NSAutoreleasePool
- From: Greg Guerin <email@hidden>
- Date: Thu, 3 Sep 2009 08:17:25 -0700
Horst Jäger wrote:
NSDictionary *di = [[NSDictionary alloc] init];
NSArray *ar = [di allKeys];
di is an empty NSDictionary. Therefore, ar will always be an empty
immutable NSArray. Consequently, it's possible to return a singleton
empty NSArray that's never released. I'm not saying this *is*
happening, just that it *could* happen under the memory mgmt rules.
The code is fatally flawed because it doesn't follow the memory mgmt
rules. All observed effects (like NSLog'ing the retainCount) rely on
unspecified side-effects. You shouldn't be surprised when
unspecified side-effects occur, nor should you count on them always
occurring in the same way.
-- GG
_______________________________________________
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