利用forwardInvocation和First Responder在xcode联接未定义的Action

来源:互联网 发布:三洋air9s性能数据 编辑:程序博客网 时间:2024/05/18 01:47
因为要在多个类的对象中调用相同的方法名,因此在一个通用类中重载了forwardInvocation方法。

- (void)forwardInvocation:(NSInvocation *)anInvocation

{

id controller = [tabViewItemmyController];

SEL aSelector = [anInvocationselector];

[controllerperformSelector:aSelector];

}

但是在给控件联接First Responder联接selector时,却连接不上,之前的代码虽连接上了,只是显示了一个叹号,提示未定义的Selecor. 但程序的运行是不存在任何问题的,也能正确地响应selector,

处理方法,在任意处增加一个mycation:(id)sender函数,然后控件的@selector联接到First Responder的my cation,然后再删除myaction方法,因为个在forwardInvocation中会调用到各数类的my action方法。


0 0