• 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: Bill Cheeseman <email@hidden>
  • Date: Tue, 06 Aug 2002 18:00:56 -0400

on 02-08-06 3:57 PM, Ondra Cada at email@hidden wrote:

> Particularly, I am afraid the difference between owned (like window title)
> and referenced (like window delegate) object is very important, and not
> stressed out enough in Cocoa (the more so since for both are often used
> the very same operations).
>
> With this distinction on mind, it should be emphasized we are speaking of
> accessors to owned objects here.

This is a helpful distinction to me.

Recently, I was playing with the Cocoa text system and reached the point
where I had a pointer to my textview's NSTextStorage object. I made a setter
and getter for my reference to it, but then I thought that my setter
probably shouldn't retain and release per the usual setter pattern because I
don't own the NSTextStorage -- I just have a reference or pointer to it, for
my convenience.

The text system documentation says that when I release an NSTextStorage
object, the text system will release its NSLayoutManagers and
NSTextContainers and I think its NSTextViews. So I suppose I can't retain
and release without disrupting my text system. After releasing it, I suppose
I would have to build the whole system back up again properly.

I give this as an example of the confusion that accessor theory and memory
management can bring to a relative beginner. What is the answer for
NSTextStorage? When I'm just pointing to it, I shouldn't retain and release
in a convenience setter, is this right?

--

Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com

The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
Croquet Club of Vermont - http://members.valley.net/croquetvermont
_______________________________________________
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: Accessor methods and (auto)release: conclusion
      • From: Marcel Weiher <email@hidden>
References: 
 >Re: Accessor methods and (auto)release: conclusion (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: NSWindow setMiniwindowImage seems to do nothing
  • Next by Date: Re: Accessor methods and (auto)release: conclusion
  • Previous by thread: Re: Accessor methods and (auto)release: conclusion
  • Next by thread: Re: Accessor methods and (auto)release: conclusion
  • Index(es):
    • Date
    • Thread