• 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
patching the responder chain: puzzled by the docs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

patching the responder chain: puzzled by the docs


  • Subject: patching the responder chain: puzzled by the docs
  • From: Andy Lee <email@hidden>
  • Date: Fri, 22 Jan 2010 12:42:58 -0500

My understanding was that it's okay to insert things anywhere you want in the responder chain.  In particular, it's okay to put a a view controller between its view and the view's superview.  I know I'm not alone in this:

 * Buck and Yacktman say so in "Cocoa Design Patterns," in the section "Inserting Objects into the Responder Chain."
 * Jonathan Dann offered a way for view controllers to get patched in automatically, and nobody said boo: <http://www.cocoabuilder.com/archive/cocoa/212830-responder-chain-patching.html#212954>.
 * In the same thread, Matt Neuberg (no slouch) said he does it all the time, though with a custom NSResponder rather than a view controller: <http://www.cocoabuilder.com/archive/cocoa/212830-responder-chain-patching.html?q=Responder+Chain+Patching#212862>.
 * On the iPhone, UIKit's responder chain is structured this way by default.

But today I noticed this:

<http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/EventArchitecture.html>
"A view’s next responder is always its superview—most of the responder chain, in fact, comprises the views from a window’s first responder up to its content view. When you create a window or add subviews to existing views, either programmatically or in Interface Builder, the Application Kit automatically hooks up the next responders in the responder chain. The addSubview: method of NSView automatically sets the receiver as the new subview’s superview. You should never send setNextResponder: to an NSView object."

Because of what addSubview: does, I can see you have to be careful *when* you send setNextResponder: to a NSView.  But *never*?  Are the docs wrong?  Or is this a real Apple rule that people commonly violate at their own risk, like the rule about not starting method names with underscores?  If so, what is that risk?

--Andy

_______________________________________________

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: patching the responder chain: puzzled by the docs
      • From: Andy Lee <email@hidden>
  • Prev by Date: Re: UIImageView display as "multiply"?
  • Next by Date: Re: CALayer resizing puzzle
  • Previous by thread: Re: KVO and object release timing (for a NSCollectionView)
  • Next by thread: Re: patching the responder chain: puzzled by the docs
  • Index(es):
    • Date
    • Thread