NSInvocationを使用してオブジェクトのメソッドを呼び出し、をsender
引数として送信しようとしています。以下のコードはmthodを呼び出しますが、オブジェクトがmthodに渡されているようですが、実際には自己オブジェクトではありません
- (void)setTarget:(id)taret withAction:(SEL)selector
{
NSMethodSignature *methodSignature = [target methodSignatureForSelector:action];
_invocation = [[NSInvocation invocationWithMethodSignature:methodSignature] retain];
_invocation.target = target;
_invocation.selector = action;
[_invocation setArgument:self atIndex:2];
}
- (void)callTargetWithSender
{
[_invocation invoke];
}