开发者

Get the object which called a method

If I have a call from within a random class like this:

@implementation Some开发者_如何学JAVAClass

- (void) classMethodFoo
{
    int a = [SomeSingleton sharedInstance].aValue;
}

@end

Inside SomeSingleton sharedInstance, is there a way to get a reference to the object which called this method (without the called passing self as a parameter of course)?


No, information about the caller isn't passed along automatically.

This is why IBAction methods, for instance, have a sender parameter, and why delegate methods often have a parameter that refers to the delegate's object.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜