1.通过block获取imp
IMP imp_block = imp_implementationWithBlock(^{
NSLog(@"do something");
});
BOOL is_add = class_addMethod(NSPerson.class, @selector(travel), imp_block, "v@:");
if(is_add)
{
[NSPerson.new travel];
}
2.通过imp 获取block
id block = imp_getBlock(imp_block);
NSLog(@"%@",block);
3.移除block
BOOL is_removed = imp_removeBlock(imp_block);
NSLog(@"is_removed:%d",is_removed);