Re: NSMutableDictionary crash on PPC
Re: NSMutableDictionary crash on PPC
- Subject: Re: NSMutableDictionary crash on PPC
- From: Roland King <email@hidden>
- Date: Wed, 29 Sep 2010 16:07:41 +0800
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.
On Sep 29, 2010, at 16:02, Trygve Inda <email@hidden> wrote:
>> Did you read my post about retaining things before you remove them from
>> dictionaries?
>>
>
>
>> myDict = [myObject objectForKey:myOldKey];
>> if (myDict)
>> {
>> [myObject removeObjectForKey: myOldKey];
>> [myObject setValue:myDict forKey:myNewKey];
>>
>> [[NSUserDefaults standardUserDefaults] synchronize];
>> }
>
>
> I don't have a PPC here, but I assume that must be it. Odd though that it
> doesn't wait until the autorelease pool is flushed.
>
> There is example code here (2nd example) that removes before setting too.
>
> http://stackoverflow.com/questions/1024938/renaming-keys-in-nsmutablediction
> ary
>
> T.
>
>
_______________________________________________
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