Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Connecting cell to controller using a block
@interface MyTableViewCell
@property(nonatomic, copy) void (^checkboxHandler)(void);
@end
@implementation MyTableViewCell
- (IBAction)checkboxPressed:(UIButton *)sender {
self.checkboxHandler();
}
@end
@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