Best place to remove observer for NSViewBoundsDidChangeNotification
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