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];
}
See “Using NSInvocation” in Distributed Objects Programming Guide.
EDIT BASED ON NEW QUESTION *
I assume the above will be called this way:
In that case, the final message will be: