• 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: Responder Chain Patching
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Responder Chain Patching


  • Subject: Re: Responder Chain Patching
  • From: Jonathan Dann <email@hidden>
  • Date: Mon, 14 Jul 2008 21:10:06 +0100

Have you seen this

http://katidev.com/blog/2008/04/17/nsviewcontroller-the-new-c-in-mvc-pt-2-of-3/

and this thread

http://www.cocoabuilder.com/archive/message/cocoa/2008/3/19/201743

All of this is covered, with automatic insertion of view controllers into the responder chain.

If you want to set up the view controller as the next responder of the view (not done in the above) then you might be better with this code (thanks, Ali Lalani)

#import "MyViewController.h"


@implementation MyViewController - (void)loadView; { [super loadView];

[[self view] addObserver:self forKeyPath:@"nextResponder" options:0 context:NULL];
}


- (void)dealloc;
{
[[self view] removeObserver:self forKeyPath:@"nextResponder"];
[super dealloc];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject: (id)object change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqualToString:@"nextResponder"])
{
// when we get called due to setting next responder as ourselves we ignore it (could also unobserve right before and re- observe right after...)
if ([[self view] nextResponder] != self)
{
[self setNextResponder:[[self view] nextResponder]];
[[self view] setNextResponder:self];
}
}
else
{
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
@end


In this way the view controller will 'jump' in whenever the view's nextResponder is set.

HTH

Jon

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >Re: Responder Chain Patching (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: What is the best way?
  • Next by Date: Re: What is the best way?
  • Previous by thread: Re: Responder Chain Patching
  • Next by thread: Webkit and image redirects
  • Index(es):
    • Date
    • Thread