Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 06-04-2009, 08:42 PM   #6 (permalink)
MatuX
Registered Member
 
Join Date: May 2009
Posts: 87
Default

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?

Last edited by MatuX; 06-04-2009 at 08:58 PM.
MatuX is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,806
Threads: 89,205
Posts: 380,621
Top Poster: BrianSlick (7,129)
Welcome to our newest member, philipmores95
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:20 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.