Re: Beginner Questions
Re: Beginner Questions
- Subject: Re: Beginner Questions
- From: j o a r <email@hidden>
- Date: Wed, 2 Feb 2005 09:18:09 +0100
On 2005-02-02, at 03.58, James Spencer wrote:
I'm having trouble understanding how dellocation of objects
instantiated in nib files is handled. The question arises in
connection with my first Cocoa application utilizing bindings.
I have a simple document based application. The nib for the document
contains, in addition to the main window for the document, a custom
NSArrayController. The nib file's owner is the document. I have
noted that when the main window is closed, the document is being
closed and deallocated. What has me confused is that my custom
NSArrayController is NOT being deallocated. Now, obviously I can
release the controller from my document's dealloc method or I can
watch for the window's notification of it's intent to close and have
the controller release itself when it gets notified but I had thought
that in a document based application, all top level objects in the nib
(which in this case includes my array controller) would be released
when the document got released.
Can anyone give me the quick nickel tour of what get's closed when a
window, which was loaded with the rest of a nib by the document, is
closed?
If the owner of your nib file (owner = the object that loads the nib
file, the object that has the outlets that you've connected in your nib
file) is a subclass of NSWindowController, memory management for the
objects loaded from the nib file will be handled automatically for you.
The documentation for this functionality can be found here:
<http://developer.apple.com/documentation/Cocoa/Conceptual/Documents/
Concepts/WinControllersAndNibs.html>
If you on the other hand load a nib file in any other way, you are
responsible for releasing all "top level" objects in the nib file at
the appropriate time. The "top level" objects are all objects you find
in the nib file window in IB, not including the "proxy" objects - files
owner, first responder, et.c.
How do you verify that the array controller is not deallocated? Note
that it might be autoreleased, and in that case deallocation would
typically happen at the end of the current event loop and perhaps not
exactly when the document is deallocated.
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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