Get the sender of the message for an NSInvocation

旧巷老猫 提交于 2019-12-13 00:36:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!