• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Properties, Attributes and Retain+Autorelease
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Properties, Attributes and Retain+Autorelease
      • From: Markus Hanauska <email@hidden>
References: 
 >Re: Properties, Attributes and Retain+Autorelease (From: Matt Neuburg <email@hidden>)
 >Re: Properties, Attributes and Retain+Autorelease (From: Markus Hanauska <email@hidden>)
 >Re: Properties, Attributes and Retain+Autorelease (From: Kyle Sluder <email@hidden>)
 >Re: Properties, Attributes and Retain+Autorelease (From: Markus Hanauska <email@hidden>)

  • Prev by Date: Re: problem with applying md5 to data
  • Next by Date: Re: Properties, Attributes and Retain+Autorelease
  • Previous by thread: Re: Properties, Attributes and Retain+Autorelease
  • Next by thread: Re: Properties, Attributes and Retain+Autorelease
  • Index(es):
    • Date
    • Thread