Objective-C 运行时寻找匹配消息的IMP(implementation)
运行时方法的结构(用户不可见):
struct objc_method
{
SEL method_name;
char * method_types;
IMP method_imp;
};
typedef objc_method Method;
参数说明:
method_name 方法名:方法名为此方法的签名,有着相同函数名和参数名的方法有着相同的方法名。
method_types 方法类型:方法类型描述了参数的类型。
IMP: IMP即函数指针,为方法具体实现代码块的地址,可像普通C函数调用一样使用IMP。
示例:
IMP showInfo = [myView methodForSelector:@selector(showBookInfo)];
showInfo(myView, @selector(showBookInfo));