Re: Are NSViews autoreleased or released?
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