• 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
Best place to remove observer for NSViewBoundsDidChangeNotification
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Best place to remove observer for NSViewBoundsDidChangeNotification


  • Subject: Best place to remove observer for NSViewBoundsDidChangeNotification
  • From: Jonathan Dann <email@hidden>
  • Date: Mon, 25 Feb 2008 22:15:29 +0000

Hi Guys,

I have a document-based non-GC app in which I register my document instance to receive an NSViewBoundsDidChangeNotification for my [[mainTextView enclosingScrollView] contentView].

On dealloc, the document calls [[NSNotificationCenter defaultCenter] removeObserver:self], but these notifications still get sent to the dealloc'd instance when the window itself closes. I think this is something to do with the notification being sent/received in a delayed manner, am I right?

I've now overridden NSDocument's -close method to remove self from observing these notifications before calling [super close] (which works fine) but I was wondering if there was a better, more conventional place to put these -removeObserver: calls. I'm not sure if this makes sense but are there any view-related methods that get called when a document/window closes that would be the best place to de-register for observations of view notifications? Could what I've done bite me if, for example, for some reason -close does not get called?

Thanks,

Jon
_______________________________________________

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


  • Follow-Ups:
    • Re: Best place to remove observer for NSViewBoundsDidChangeNotification
      • From: Jerry Krinock <email@hidden>
  • Prev by Date: Re: BezierPath issues
  • Next by Date: Re: NSOutlineView autosaving of expanded/collapsed state
  • Previous by thread: Fwd: Chaging NSStatusItem menus.
  • Next by thread: Re: Best place to remove observer for NSViewBoundsDidChangeNotification
  • Index(es):
    • Date
    • Thread