Re: Delegate methods[SOLVED]
Re: Delegate methods[SOLVED]
- Subject: Re: Delegate methods[SOLVED]
- From: Dave Camp <email@hidden>
- Date: Wed, 20 Aug 2003 10:40:36 -0700
On Wednesday, August 20, 2003, at 06:20 AM, Neil Earnshaw wrote:
Others seem to be managed by the window adding the delegate as an
observer. The delegate doesn't know that it has been made an observer
and the documentation doesn't explicitly say,
It's documented in the Windows and Panels docs:
"NSWindow offers observers a rich set of notifications, which it
broadcasts on such occurrences as gaining or losing key or main window
status, miniaturizing, moving or resizing, becoming exposed, and
closing. Each notification is matched to a delegate method, so an
NSWindows delegate is automatically registered for all notifications
that it has methods for."
Another note for newbies: The documentation for notifications clearly
states that the observer is not retained. Unfortunately, it doesn't
point out that the observed object _is_. So, if you have any cyclic
notification chains it is _not_ sufficient to removeObserver:self in
your dealloc method because dealloc will never get called. Instead,
one of the objects in the circle must removeObserver:self outside the
dealloc method. Once the chain has been broken, then the whole lot
will get cleaned up (as long as dealloc removes the object from the
notification center).
Maybe I'm looking at the wrong thing, but the documentation for
addObserver:selector:name:object: says otherwise.
"The notification center does not retain anObserver or anObject.
Therefore, you should always send removeObserver: or
removeObserver:name:object: to the notification center before releasing
these objects."
Dave
-
It's not denial. I'm just very particular about the reality I choose to
accept. -Calvin
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.