• 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: Autorelease question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Autorelease question


  • Subject: Re: Autorelease question
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 3 Apr 2008 20:09:50 -0700


On 3 Apr '08, at 7:50 PM, Dmitry Markman wrote:

1. I read all that documentation, please, enough about that, really

Reading it isn't enough, you have to _understand_ it. I know that sometimes it can take several readings before something makes sense. Usually after you've been burned by mistakes, it suddenly becomes clearer on the next reading :)

2. I should follow the "alloc, new, copy or mutableCopy" rule. I should note
that I'm talking about creation methods not create/copy/get methods all of that
notes about looking to the name (what in your name :-)) )
3. but I agree with Adam comment that the rule isn't 100% reliable and therefore isn't good enough

Err, it's been good enough for me for seven years and counting. I didn't see Adam say anything about rules not being good enough.


Methods that return objects either "give you a reference" that has to be released later, or they don't. You can tell from the name of the methods which ones they are. In the great majority of cases, the methods you call don't require you to deal with releasing the object.

The fact that there are autorelease pools is mostly an implementation detail. The fact that an object without 'alloc' or 'copy' in its name returns an object doesn't mean it autoreleased that object. The object could be an instance variable belonging to it, for example. It doesn't matter to you.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >Autorelease question (From: Dmitry Markman <email@hidden>)
 >Re: Autorelease question (From: Robert Claeson <email@hidden>)
 >Re: Autorelease question (From: Jens Alfke <email@hidden>)
 >Re: Autorelease question (From: Dmitry Markman <email@hidden>)
 >Re: Autorelease question (From: Dmitry Markman <email@hidden>)
 >Re: Autorelease question (From: Rob Keniger <email@hidden>)
 >Re: Autorelease question (From: Dmitry Markman <email@hidden>)
 >Re: Autorelease question (From: Chris Suter <email@hidden>)
 >Re: Autorelease question (From: Dmitry Markman <email@hidden>)

  • Prev by Date: Re: Autorelease question
  • Next by Date: Re: NSCondition easter-egg hunt
  • Previous by thread: Re: Autorelease question
  • Next by thread: Re: Autorelease question
  • Index(es):
    • Date
    • Thread