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

Re: Memory Management


  • Subject: Re: Memory Management
  • From: Martin Häcker <email@hidden>
  • Date: Tue, 29 Jul 2003 00:13:37 +0200

[autoreleasing accessor]

You are not allowed to answer that I am _supposed to know_ how -name is implemented.

EXACTLY, but this is precisely what you are doing when you access the return value after its containing object is released. The only way to NOT make this assumption is to retain the result yourself when you release the container.

Senders of messages with NSObject * replies should be able to assume that the replies have at least autorelease lifetimes.

This is simply false. As a simple counterexample, all the Foundation collections do not conform to this "rule". The fact that you are using the word *assume* should also tip you off that you are breaking your own criterium that you set up just a line earlier.

I think that this ultimately boils down to a question of speed versus a more appealing thinking, especially for newbies (like me too).

The not autoreleased method does give a nicer code flow and at least to me communicates its intent a lot clearer.

Also many of the official docs state that the api always returns autoreleased objects (the collections being the notably exception) from getter methods.

Id say, try the two possibilities and stick with what works better for you.

(I also have the private hope that we will see an optional garbage collector for Obj-C soon. And that will silence this kind of discussion once and for all)

cu Martin
--
dont.wanna.tell
[ot]coder - hehe
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Memory Management (From: Marcel Weiher <email@hidden>)

  • Prev by Date: Re: Memory Management
  • Next by Date: Re: Hard Objc-Runtime question: objc_getClassList lies to me...
  • Previous by thread: Re: Memory Management
  • Next by thread: Re: Memory Management
  • Index(es):
    • Date
    • Thread