You can't get selectors like this. (For getting selectors at runtime, use the sel_getUid()
function). Also, you're confusing selectors and blocks. What you want is possible, but using a different approach:
- (void)addRightButton:(UIImage *)btnImage click:(ButtonClick)click{
UIButton *modalViewButton = [UIButton buttonWithType:UIButtonTypeCustom];
[modalViewButton addTarget:click
action:@selector(invoke)
forControlEvents:UIControlEventTouchUpInside];
}
- (void)test
{
[self addRightButton:[UIImage imageNamed:@"btn_shuaxin_1.png"] click:^{
NSLog(@"it is test code");
}];
}