Thanks a lot for all of your responses!
Common sense dictated to me that since I wasn't retaining the object I just allocated (and I was giving it directly to another object), the retain count wouldn't increase.
Does this means that if I do
[obj setSomething:[[OtherObj alloc] init]; it will automatically become a leak? If it is so, why the compiler doesn't signal a warning here?
So the rule is that
every time I do "alloc", the retain count increases 1 and I am the one responsible to decrease it?
Edit:
If that is the rule, isn't there a way to stop the language from doing this? It will make the code really messy if I can't do something like:
Code:
[myObj setThis:[[OtherObj alloc] init];
and I'm forced to add these redundant lines:
Code:
OtherObj otherObj = [[OtherObj alloc] init];
[myObj setThis:otherObj];
[otherObj release];
------
And what if the property is set to assign instead of retain? When I do "release" I will render the allocated memory unusable?
Must I check for
every property if its set to assign or retain every time I use it?