• 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: KVO de-observation difficulties when closing a window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVO de-observation difficulties when closing a window


  • Subject: Re: KVO de-observation difficulties when closing a window
  • From: Jamie Johnson <email@hidden>
  • Date: Sun, 13 May 2012 19:08:25 -0700

Observe NSWindowWillCloseNotification via NSNotificationCenter. You will get notified. The delegate should get the notification but it's possible the delegate is getting set nil prior.

On May 13, 2012, at 6:18 PM, Graham Cox wrote:

> This is proving a lot harder that I feel it should be.
>
> I am KVO observing the accessory view property of an NSRulerView, so that I can install different views into the accessory area when the standard text controls are removed. The ownership of the NSRulerView is quite complicated, as it's part of an NSScrollView, which in turn is owned by a bunch of other views and ultimately the window.
>
> I can remove my KVO observation in the window delegate's -windowWillClose: method, and that's fine as far as it goes. But it's not always called, leaving me with the dreaded 'KVO observers were still attached when an object was deallocated' error in some cases (in particular, when the 'Save' dialog shows up and Don't Save is clicked - maybe for other cases as well).
>
> Is there a place I can reliably get notified when a window will close, no matter what pathway it took to close that window, whether a save was involved, whether it was closed by a manual click in the close button or closed by some other means, but BEFORE any of its internal structure is released (views in particular)? Surely there's a reliable place for this?
>
> Ideally I'd prefer a delegate method since I'm not subclassing NSWindow in this case.
>
>
> --Graham
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >KVO de-observation difficulties when closing a window (From: Graham Cox <email@hidden>)

  • Prev by Date: KVO de-observation difficulties when closing a window
  • Next by Date: [SOLVED] Re: KVO de-observation difficulties when closing a window
  • Previous by thread: KVO de-observation difficulties when closing a window
  • Next by thread: [SOLVED] Re: KVO de-observation difficulties when closing a window
  • Index(es):
    • Date
    • Thread