On Sep 29, 2010, at 16:02, Trygve Inda 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 dictio
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 s
> 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]
Did you read my post about retaining things before you remove them from
dictionaries?
On Sep 29, 2010, at 15:29, Trygve Inda wrote:
>> On Sep 28, 2010, at 22:48, Trygve Inda wrote:
>>
>>> [myObject removeObjectForKey:myDict];
>>
>> Shouldn't that be:
>>
>> [myObject removeObjectForKey:my
> On Sep 28, 2010, at 22:48, Trygve Inda wrote:
>
>>[myObject removeObjectForKey:myDict];
>
> Shouldn't that be:
>
> [myObject removeObjectForKey:myOldKey];
>
> ?
Yes. Sorry - typing in Mail.
Correct code (still crashes on PPC)
myDict = [myObject objectForKey:myOldKey];
if (myDict)
{
Is that really the code? you're removing the object for the key myDict but that
isnt the key, its the object for key myOldKey. Are you sure the
removeObjectForKey doesn't really have the parameter myOldKey?
You dont say what the crash is but you're not retaining the object myDict you
remove fro
On Sep 28, 2010, at 22:48, Trygve Inda wrote:
>[myObject removeObjectForKey:myDict];
Shouldn't that be:
[myObject removeObjectForKey:myOldKey];
?
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests o
I am getting a crash after calling synchronize. I am trying to change the
key associated with an object as follows:
myDict = [myObject objectForKey:myOldKey];
if (myDict)
{
[myObject removeObjectForKey:myDict];
[myObject setValue:myDict forKey:myNewKey];
[[NSUserDefaults standardUser