因为要在多个类的对象中调用相同的方法名,因此在一个通用类中重载了
forwardInvocation方法。
- (void)forwardInvocation:(NSInvocation *)anInvocation
{
id controller = [tabViewItem myController];
SEL aSelector = [anInvocation selector];
[controller performSelector:aSelector];
}
但是在给控件联接First Responder联接selector时,却连接不上,之前的代码虽连接上了,只是显示了一个叹号,提示未定义的Selecor. 但程序的运行是不存在任何问题的,也能正确地响应selector,
处理方法,在任意处增加一个mycation:(id)sender函数,然后控件的@selector联接到First Responder的my cation,然后再删除myaction方法,因为个在
forwardInvocation中会调用到各数类的my action方法。