• 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 09:09:28 -0700

On Wed, 29 Jun 2011 12:53:26 +0200, Markus Hanauska <email@hidden> said:
>E.g. consider the following code:
>
>	ObjectCreator oc = [[ObjectCreator alloc] init];
>	id value = [oc value];
>	[oc release];
>	[value someMethod];
>

We actually had something very like this discussion here already recently:

http://lists.apple.com/archives/cocoa-dev/2011/Mar/threads.html

(Look at the thread titled "NSAttributedString crashes".)

As I said then, "Ownership is *never* something you are magically given. It is always something that you must take if you want it." Perhaps that answer isn't very satisfactory, but at least it provides a philosophy that covers the case. As Andy Lee says in that same thread, "We've been conditioned to think we have "extra persistence time" at least up to the next run loop iteration," but (I think he's implying) this conditioning is specious and serves only to make us lazy. To put it another way: ObjectCreator's "value" method is opaque; to pretend that you *know* its memory-management policy is really just a case of programming by guesswork. m.

--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook_______________________________________________

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>
    • Re: Properties, Attributes and Retain+Autorelease
      • From: Markus Hanauska <email@hidden>
  • Prev by Date: Re: How to assign a method for touch event to a UIImageView?
  • Next by Date: Re: who is currently the first responder? (iOS)
  • Previous by thread: Re: Properties, Attributes and Retain+Autorelease (SOLVED)
  • Next by thread: Re: Properties, Attributes and Retain+Autorelease
  • Index(es):
    • Date
    • Thread