Created
July 19, 2013 11:43
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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