Created
August 15, 2014 00:30
-
-
Save zmcartor/73bcc143faa99af202b3 to your computer and use it in GitHub Desktop.
Cocoa Responder Chain and UITableViews
This file contains hidden or 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
// Whenever a button, tap , or something 'happens' within a cell subclass, send a message up thee olde Responder Chain | |
// -- within tablecell_subclass.m | |
- (IBAction)connectButtonClicked:(id)sender { | |
SEL selConnectButton = sel_registerName("connectButtonResponder:"); | |
[[UIApplication sharedApplication] sendAction:selConnectButton to:nil from:self forEvent:nil]; | |
} | |
// within the UITableViewController , responde to the selector "connectButtonResponder" | |
- (IBAction)connectButtonResponder:(id)sender { | |
NSAssert([sender class] == [tablecell_subclass class], @"something not expected was attached to connectButtonResponder: - you're a bad person"); | |
UITableCell *cell = (UITableCell*)sender; | |
NSIndexPath *path = [self.tableView indexPathForCell:cell]; | |
NSDictionary *someDatas = [self.datas objectAtIndex:path.row]; | |
// .. do other things and respond to the event | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment