Skip to content

Instantly share code, notes, and snippets.

@tmdvs
Last active January 26, 2020 02:31
Show Gist options
  • Save tmdvs/6625390 to your computer and use it in GitHub Desktop.
Save tmdvs/6625390 to your computer and use it in GitHub Desktop.
UISwitch with block handler
@interface UIBlockSwitch : UISwitch {
ActionBlock _actionBlock;
}
-(void) handleControlEvent:(UIControlEvents)event
withBlock:(ActionBlock) action;
@end
@implementation UIBlockSwitch
-(void) handleControlEvent:(UIControlEvents)event
withBlock:(ActionBlock) action
{
_actionBlock = action;
[self addTarget:self action:@selector(callActionBlock:) forControlEvents:event];
}
-(void) callActionBlock:(id)sender{
_actionBlock();
}
@end
@JazzSoft
Copy link

Where is ActionBlock?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment