• 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: NSDictionary, allKeys and the NSAutoreleasePool
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Trouble with NSButtonCell
  • Next by Date: What about revamping OpenUp.app for Snow Leopard?
  • Previous by thread: Re: NSDictionary, allKeys and the NSAutoreleasePool
  • Next by thread: Overriding NSTextTable behaviour in NSTextView
  • Index(es):
    • Date
    • Thread