• 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: Accessor methods and (auto)release: conclusion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessor methods and (auto)release: conclusion


  • Subject: Re: Accessor methods and (auto)release: conclusion
  • From: Marcel Weiher <email@hidden>
  • Date: Tue, 6 Aug 2002 19:51:35 +0200

On Tuesday, August 6, 2002, at 07:44 Uhr, Ondra Cada wrote:


On Tuesday, August 6, 2002, at 07:36 , Marcel Weiher wrote:

...Deallocs should not have side-effects, they should just remove the object in question.

Notice the word *remove* in the sentence above.

Oh, so eg. all those [[NSNotificationCenter defaultCenter] removeObserver:
self] in so many of my -deallocs are all wrong? Gee.

Notice the word *remove* in the sentence above.

I think the sentence of yours is just not true. Deallocs should have as many sideeffects as needed for *proper removing the object in the environment it lives* -- including things like keeping observer list up to date, keeping any named lists (like the Window menu or whatever similar one might have in one's applicaiton) up to date, closing potential sockets the object might use, and who knows what more.

Sure, but using set-accessors is not a generally good pattern for doing this. For this to be acceptable, you have to know that the accessor will not have other side effects, which isn't a safe assumption to make. Of course, you can have a coding style that makes sure of that, but that doesn't make it a generally acceptable pattern.

Marcel
_______________________________________________
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:
    • Usage of accessor methods (was: Accessor methods and (auto)release: conclusion)
      • From: Ondra Cada <email@hidden>
References: 
 >Re: Accessor methods and (auto)release: conclusion (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: Who is releasing my CFAllocator?
  • Next by Date: Usage of accessor methods (was: Accessor methods and (auto)release: conclusion)
  • Previous by thread: Re: Accessor methods and (auto)release: conclusion
  • Next by thread: Usage of accessor methods (was: Accessor methods and (auto)release: conclusion)
  • Index(es):
    • Date
    • Thread