Skip to content

Instantly share code, notes, and snippets.

@richardbuckle
Created July 19, 2013 11:43
Show Gist options
  • Save richardbuckle/6038567 to your computer and use it in GitHub Desktop.
Save richardbuckle/6038567 to your computer and use it in GitHub Desktop.
Use a nil-targeted action to message a view controller higher up the responder chain without introducing coupling
// in some parent view controller's header file
- (IBAction)yourActionNameHere:(id)sender;
// implementation does whatever you want
// Now, from any call site, as long as you're on the main thread
// just post an action to nil and it will be sent to the first responder,
// then all the way up the responder chain until it finds your view controller
[[UIApplication sharedApplication] sendAction:@selector(yourActionNameHere:)
to:nil
from:self
forEvent:nil];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment