• 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: Are NSViews autoreleased or released?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Are NSViews autoreleased or released?


  • Subject: Re: Are NSViews autoreleased or released?
  • From: Shawn Erickson <email@hidden>
  • Date: Mon, 5 Dec 2005 18:16:31 -0800

On 12/5/05, Kaspar Fischer <email@hidden> wrote:
> Hi,
>
> Are NSViews autoreleased or released? For instance, when a
> window gets closed, are the window's views and subviews
> released or autoreleased?

It doesn't matter since if an object is sent an autorelease message it
will get a release message when the related autorelease pool gets
dealloced (one for each autorelease message sent). Also the use of
release or autorelease is an implementation detail of the framework
that shouldn't be depended on (unless documented otherwise).

> If they are released, I should probably deregister the view
> (from being an observer) and unbind its contents in -[dealloc].
> But what if they are autoreleased? Where can I deregister the
> view from being an observer (unbind, resp.) then?

As outlined above, autorelease results in a release message at some
future point. In other words you end up in dealloc for either
(assuming retain count reaches zero).

You may want to go back and review Apple documentation on memory
management and autorelease/NSAutoreleasePool.

<http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Concepts/ObjectOwnership.html#//apple_ref/doc/uid/20000043>
<http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Concepts/AutoreleasePools.html#//apple_ref/doc/uid/20000047>
etc.

-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Are NSViews autoreleased or released?
      • From: Kaspar Fischer <email@hidden>
References: 
 >Are NSViews autoreleased or released? (From: Kaspar Fischer <email@hidden>)

  • Prev by Date: How to deal with : "...XXX is being deallocated while key value observers are still registered with it..."
  • Next by Date: Re: Saving C++ based data structures
  • Previous by thread: Are NSViews autoreleased or released?
  • Next by thread: Re: Are NSViews autoreleased or released?
  • Index(es):
    • Date
    • Thread