views:

56

answers:

3

Hey - does somebody know why i get a leak when i use this line of code ??? :

[self setModules:[[aDictionary objectForKey:KEY_MODULES] mutableCopy]];

Thanks in advance pk

+5  A: 

As you create a copy of existing object via mutableCopy then you're responsible to release it (assuming you also retain it in setModules method):

[self setModules:[[[aDictionary objectForKey:KEY_MODULES] mutableCopy] autorelease]];

Check also that you release modules iVar in your class's dealloc method.

Vladimir
bleh you beat me as usual :)
willcodejavaforfood
@willcodejavaforfood so sorry :)
Vladimir
@Vladimir - +1 for being sorry :)
willcodejavaforfood
+1  A: 

mutableCopy creates a new copy with a retainCount of 1 and needs to be released.

[self setModules:[[[aDictionary objectForKey:KEY_MODULES] mutableCopy] autorelease]];
willcodejavaforfood
Actually, it creates a copy with a retain count of *at least* 1.
JeremyP
A: 

Thank you very much !!!

Peeeble