问题
How do I get the sender of the message wrapped in an `NSInvocation?
I'm in an object, and I've just received an invocation in my forwardInvocation:
.
Is there any way to know who sent me the message in the first place?
回答1:
No. Information about the sender is not available (unless you explicitly add an sender:self
argument).
See also this thread http://www.cocoabuilder.com/archive/cocoa/194746-is-the-sender-of-an-obj-method-implied-in-the-destination-method.html:
It isn't explicitly available, nor can you consistently unwind the stack to figure it out. Nor is there even a guarantee that the "sender" is really some Objective-C object; it could just as easily be a function or FFI produced closure, in the case of the various language bridges.
b.bum
来源:https://stackoverflow.com/questions/22745360/get-the-sender-of-the-message-for-an-nsinvocation