Skip to content

Instantly share code, notes, and snippets.

@theoknock
Created September 20, 2021 14:12
Show Gist options
  • Save theoknock/2cf9d2f4e9213a646e526d515aa6fc46 to your computer and use it in GitHub Desktop.
Save theoknock/2cf9d2f4e9213a646e526d515aa6fc46 to your computer and use it in GitHub Desktop.
//
// ViewController.m
// TargetActionCustomPayloadsDemo
//
// Created by James Alan Bush on 9/18/21.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self.slider addTarget:
^ (UISlider * i, UIControlEvents events) {
return ^ {
NSLog(@"Touchdown");
};
}(self.slider, (UIControlEvents)UIControlEventTouchDown)
action:@selector(invoke) forControlEvents:(UIControlEvents)UIControlEventTouchDown];
void(^(^block)(UISlider *, UIControlEvents))(void) = ^ {
return ^ (UISlider * i, UIControlEvents events) {
return ^ {
printf("-");
};
};
}();
[self.slider addTarget:block(self.slider, (UIControlEvents)UIControlEventTouchDown)
action:@selector(invoke) forControlEvents:(UIControlEvents)UIControlEventValueChanged];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment