我正在编写一个自定义帮助方法,该方法会被大量使用并返回几个按钮。每个按钮在按下时当然会有自己的目标选择器,我想将选择器作为参数传递给此方法,以便返回的按钮具有指定的选择器。
但我不确定如何将选择器作为方法参数传递。像这样的东西:
-(returnedInstance)someMethod:(WhatClass?*)selectedFunction{
[SomeClassWithASelectorParameter method:whatever selector:@selector(selectedFunction)];
}
其中selectedFunction
是传递给方法的参数。
我尝试制作WhatClass?*
NSString 和 SEL,但结果是:
[NSInvocation invocationWithMethodSignature:]:方法签名参数不能为nil