• 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: How far with accessors?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How far with accessors?


  • Subject: Re: How far with accessors?
  • From: Marco Scheurer <email@hidden>
  • Date: Thu, 27 May 2004 20:00:06 +0200

Presumed that in an ideal case, unless there are strong reasons otherwise,

*** a vended object should remain valid in the scope of the current autorelease pool *** ("the presumption")

the reasons are self-evident.

[...]

(Well I do know you and Marcel and probably more people don't think the presumption is right. On the other hand, others, including at least some of the Cocoa implementors themselves, do; the combination of an autoreleasing setter and plain getter or otherwise is actually recommended in the docs. Therefore, let's decide anybody for himself.)

The autorelease setter was introduced as a shortcut (or possibly as a hack or workaround because the obvious "release then retain" fails), not for the reason you invoke. According to your own logic this is proved by the fact that nowhere in the same doc an autorelease is used in dealloc.

(A better pattern for a setter accessor is to use release in the setter but verify that the parameter is not the same as the ivar, or to retain the parameter before releasing the ivar. That's more code than using autorelease, but that's irrelevant because it can and should be automated.)

otherwise I see no reasons why your dealloc should use autorelease instead of release

Namely: if you don't use autoreleasing getter, you have to use autoreleasing setter and dealloc both *so as to fulfill the presumption* (of course you may NOT WANT TO, but that's a different question).

I didn't realize it was another way of fulfilling this untenable presumption, since I was under the impression that only autoreleasing getters were good according to you.

So we agree that if you do not presume such things then there's no reason not to use release in dealloc (nor in the setter accessor).

We obviously disagree on the merit of this presumption, but that's a well known story.

Marco Scheurer
Sen:te, Lausanne, Switzerland http://www.sente.ch
_______________________________________________
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.


  • Follow-Ups:
    • Re: How far with accessors?
      • From: Ondra Cada <email@hidden>
References: 
 >Fwd: How far with accessors? (From: Ondra Cada <email@hidden>)
 >Re: How far with accessors? (From: Jeff Biggus <email@hidden>)
 >Re: How far with accessors? (From: cricket <email@hidden>)
 >Re: How far with accessors? (From: Jeff Biggus <email@hidden>)
 >Re: How far with accessors? (From: Ondra Cada <email@hidden>)
 >Re: How far with accessors? (From: Marco Scheurer <email@hidden>)
 >Re: How far with accessors? (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: Retaining NSInputStream working with NSStream
  • Next by Date: 30 day trial howto?
  • Previous by thread: Re: How far with accessors?
  • Next by thread: Re: How far with accessors?
  • Index(es):
    • Date
    • Thread