• 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: NSMutableDictionary crash on PPC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableDictionary crash on PPC


  • Subject: Re: NSMutableDictionary crash on PPC
  • From: Martin Wierschin <email@hidden>
  • Date: Wed, 29 Sep 2010 10:35:17 -0700

On Sep 29, 2010, at 16:02, Trygve Inda <email@hidden> wrote:

There is example code here (2nd example) that removes before setting too.

http://stackoverflow.com/questions/1024938/renaming-keys-in-nsmutabledictionary

That 2nd example shouldn't be followed. Either retain the value obtained from the dictionary before removing the key, or store the value using the new key before removing the old key.



On 2010.09.29, at 1:07 AM, Roland King wrote:

There's nothing odd about it. It's simple memory management rules. The moment you remove the object from the dictionary the dictionary is no longer an owner and since you've not retained it, neither are you. If nobody else is, it's subject to dealloc as soon as the dictionary releases it If it so happens it is on an outer autorelease pool on PPC that's just lucky.

I think there is a warning about this in the documentation too.

Yes, see:

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ MemoryMgmt/Articles/mmObjectOwnership.html#//apple_ref/doc/uid/ 20000043-1000922

When an object is removed from one of the fundamental collection classes, it is sent a release (rather thanautorelease) message. If the collection was the only owner of the removed object, the removed object (heisenObjectin the example ) is then immediately deallocated.


~Martin

_______________________________________________

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: 
 >Re: NSMutableDictionary crash on PPC (From: Trygve Inda <email@hidden>)
 >Re: NSMutableDictionary crash on PPC (From: Roland King <email@hidden>)

  • Prev by Date: portable app
  • Next by Date: Re: Core data: Inverse relationships with subclasses
  • Previous by thread: Re: NSMutableDictionary crash on PPC
  • Next by thread: Re: NSMutableDictionary crash on PPC
  • Index(es):
    • Date
    • Thread