Re: Retains and bindings
Re: Retains and bindings
- Subject: Re: Retains and bindings
- From: Keith Renz <email@hidden>
- Date: Fri, 22 Oct 2004 02:33:21 -0400
- Resent-date: Fri, 22 Oct 2004 02:33:41 -0400
- Resent-from: Keith Renz <email@hidden>
- Resent-message-id: <email@hidden>
- Resent-to: Cocoa-Dev List <email@hidden>
I'm sure this has graduated to a FAQ by now, but of course the
archive search is no good. I'm loading a perfectly normal nib with
bindings, and I want to figure out how to release everything
correctly. I save the top-level objects and release them all
(twice!), the window (panel, actually) is set to release on close,
and so on. The NSObjectController still ends up with a retain count
of 62 (yes, the object is still valid at that point; it's not garbage
data). What do I have to be releasing and how in order to get the
objects, including the owner, to deallocate?
See:
Bindings and File's Owner
http://theobroma.treehouseideas.com/document.page/18
- Scott
Scott,
I noticed this issue several weeks ago. My window controller subclass
wasn't getting released, thus the window controller's dealloc method
never gets called and anything else needing to be released isn't. So,
the window controller and its resources are leaked. Here's how I solved
it.
I have an NSArrayController in my nib. File's Owner is a subclass of
NSWindowController. I setup and outlet in my window controller for the
NSArrayController. My window controller subclass is also the window's
delegate. I unbind the NSArrayController in the windowWillClose:
delegate method which releases the window controller and seems to clear
up the memory leak.
- (void)windowWillClose:(NSNotification *)notification
{
// NOTE: For some reason, binding contentArry to File's
Owner.document.flights in the nib retains this controller. Closing the
document no longer releases this controller, i.e a leak. If this
binding is removed in the nib, this controller is released as always.
Unbinding here releases this controller and fixes the leak, but I think
it's a bug.
[flightsController unbind:@"contentArray"];
}
Keith
_______________________________________________
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