Re: Properties, Attributes and Retain+Autorelease
Re: Properties, Attributes and Retain+Autorelease
- Subject: Re: Properties, Attributes and Retain+Autorelease
- From: Matt Neuburg <email@hidden>
- Date: Wed, 29 Jun 2011 11:08:40 -0700
On Jun 29, 2011, at 10:39 AM, Markus Hanauska wrote:
> If that was allowed, one would have to write code like this:
>
> id value = [someObject value];
> [value retain];
> [someOtherObject setValue:value];
> [value release];
That's silly. You didn't release someObject this time, so now there's no need to worry about the lifetime of value. It's the explicit [someObject release] in the original example that prompted my response; if you remove that, there's nothing to talk about.
Typically what I do is release everything that needs releasing in a clump at the end of a method. That way, no problem arises, so I don't have to add extra retains. This entire discussion (as far as I'm concerned, anyway) arises purely out of your early deliberate release of someObject. m.
--
matt neuburg, phd = email@hidden, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
Programming iOS 4! http://www.apeth.net/matt/default.html#iosbook
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com
_______________________________________________
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