#import <objc/objc-runtime.h>
demo下载地址:http://download.youkuaiyun.com/detail/xlsn0w/9429158
typedef void (^xlBlock)(idself, SEL _cmd, NSString *string);
+ (BOOL)resolveInstanceMethod:(SEL)sel {
xlBlock block = ^(idself, SEL _cmd, NSString *string) {
NSLog(@"22%@", string);
};
if (sel == @selector(xlAction:)) {
class_addMethod([selfclass], @selector(xlAction:),imp_implementationWithBlock(block), "v@:@");
}
return YES;
}
void xlFunc (idself, SEL _cmd, NSString *string) {
NSLog(@"333xl");
}
- (void)viewDidLoad {
[superviewDidLoad];
// Do any additional setup after loading the view.
[selfperformSelector:@selector(xlAction:)withObject:@"xl"];
}