开发者

Determine the class of a singleton method's caller

I've got a singleton object (in Objective C, for what that's worth). Given any particular method defined in the singleton, can I determine the class of the object which is calling it? Short of modifying the method signature to require I pass an instance of the caller (because then I'd开发者_如何学Go have to modify code everywhere the method is called).

that is, given the call from myObj

[[MySingleton instance] myMethod];

can myMethod know that it's a myObj which is calling it? I want to avoid (if I can) having to change code to something like

[[MySingleton instance] myMethodCalledBy:self];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜