Last active
January 26, 2020 02:31
-
-
Save tmdvs/6625390 to your computer and use it in GitHub Desktop.
UISwitch with block handler
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
@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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where is ActionBlock?