• 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: Delegate methods[SOLVED]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Follow-Ups:
    • Re: Delegate methods[SOLVED]
      • From: Neil Earnshaw <email@hidden>
References: 
 >Re: Delegate methods[SOLVED] (From: Neil Earnshaw <email@hidden>)

  • Prev by Date: [OT] Creating custom keyboard layout
  • Next by Date: Different selectors for different keystrokes
  • Previous by thread: Re: Delegate methods[SOLVED]
  • Next by thread: Re: Delegate methods[SOLVED]
  • Index(es):
    • Date
    • Thread