• 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
How to get rid of an NSWindowController? Or: Who is retaining my window controllers?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to get rid of an NSWindowController? Or: Who is retaining my window controllers?


  • Subject: How to get rid of an NSWindowController? Or: Who is retaining my window controllers?
  • From: Christian Gottschall <email@hidden>
  • Date: Mon, 4 Oct 2004 12:22:02 +0200

Hi,

I have a document-based Cocoa application with several NIB files. Each NIB file contains, among other things, a window. For each NIB file, I have a subclass of NSWindowController, say, MyWindowController. For loading the NIB file and displaying the respective window, I use the following code within my document class:

MyWindowController *c = [[MyWindowController alloc] initWithWindowNibName: @"MyWindow"];
[self addWindowController: c];
[c showWindow: self];
[[c window] makeKeyAndOrderFront: self];
[c release];

This works perfectly: The NIB file gets loaded, the window is displayed, and ObjectAlloc shows a count of 1 both for NSWindow and for MyWindowController.

The problem is: When the user closes the window, neither the NSWindow nor MyWindowController nor, as it seems, the NSArrayController from the same NIB file gets deallocated. When I close the last window of the document, MyDocument does get deallocated, though, and ObjectAlloc shows its count going back to 0.

Someone seems to be retaining my window controllers, but I don't know who. ;-/ I have set my windows to "Release when closed" in IB, but this does not help.

I have found a few references to similar problems, but all I understood was that using bindings might somehow introduce some circular references. Well, I actually use bindings, but even so: Is there a simple way of getting rid of an unused window controller, or do I have to do something very complicated?

Somewhere there has been a suggestion to programmatically removing certain bindings when closing the window. Not only does this seem a bit tedious, but as of now I do not understand what bindings might be responsible, and, hence, what bindings to remove.

One suggestion I read was that bindings going through file's owner cause a circular retaining relationship. In fact, I have such a binding in most, but not all of my NIBs. Unfortunately, the single NIB that has no such binding doesn't get released, either.

Is there any help in any way...?

Best regards,
Christian
--
http://logik.phl.univie.ac.at//~chris/

_______________________________________________
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: How to get rid of an NSWindowController? Or: Who is retaining my window controllers?
      • From: Shaun Wexler <email@hidden>
  • Prev by Date: Re: fileWrapperRepresentationOfType: is not called
  • Next by Date: howto get global mouse states
  • Previous by thread: RE: RE: Re: fileWrapperRepresentationOfType: is not called
  • Next by thread: Re: How to get rid of an NSWindowController? Or: Who is retaining my window controllers?
  • Index(es):
    • Date
    • Thread