I am trying to use NSInvocation to call a method on an object and send the sender
as an argument. The code below calls the mthod but it seems like the object is passing to the mthod is not really self object
- (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];
}