• 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: Window Closing Behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Window Closing Behavior


  • Subject: Re: Window Closing Behavior
  • From: John Nairn <email@hidden>
  • Date: Wed, 27 Jul 2005 11:49:22 +0200

I am confused about closing windows in a document that has more than one window controller to manage multiple window types. There are actually two types of controllers, but several instances of one of the controllers may exist at the same time. According to Apple documentation:

When a secondary window of a document is closed, only that window is closed. The window controller is removed from the document’s list of window controllers. The secondary window and its window controller are released.

Sometimes that is true, but other times the window stays in the list of window controllers and its window controller is not released. I monitored retain and release to make sure there were no unbalanced calls. What can cause a window controller to not be removed from list of window controllers and to not be released when it closes? Or how to explain that is released sometimes but not others?

I found the cause, but not the solution. In my application, the data in the window might change requiring the window controller to change the notifications it observes. When the data changes, I remove it as an observer using


[[NSNotificationCenter defaultCenter] removeObserver:self];

and then create the new observations with several "addObserver" calls. If I remove the "removeObserver" line, the window controller is always removed and released correctly. If it is there, the window controller releasing is messed up whenever a removeObserver occurs between opening and closing the window.

But I sometimes need to remove the window controller as observer. Is this a bug?

---------------
John Nairn (1-801-581-3413, FAX:1-801-581-4816)
Web Page: http://www.mse.utah.edu/~nairn

_______________________________________________
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: Window Closing Behavior
      • From: Jim Hamilton <email@hidden>
  • Prev by Date: Re: Custom line breaking in NSTextView
  • Next by Date: Re: NSTreeController drag and drop
  • Previous by thread: Window Closing Behavior
  • Next by thread: Re: Window Closing Behavior
  • Index(es):
    • Date
    • Thread