Last active
August 29, 2015 14:10
-
-
Save mikeabdullah/4026898e96860a03a8c3 to your computer and use it in GitHub Desktop.
Connecting cell to controller using a block
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
@interface MyTableViewCell | |
@property(nonatomic, copy) void (^checkboxHandler)(void); | |
@end |
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
@implementation MyTableViewCell | |
- (IBAction)checkboxPressed:(UIButton *)sender { | |
self.checkboxHandler(); | |
} | |
@end |
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
@implementation MyTableViewController | |
- (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { | |
MyTableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"cell" | |
forIndexPath:indexPath; | |
cell.checkboxHandler = ^{ | |
// Perform the desired work in response to checkbox | |
}; | |
return cell; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment