Yuri Yuri - 1 year ago 87
Objective-C Question

Objective-c get object that was called selector

Is it possible to get id pointer to object which was called selector inside function with no sender argument?

- (void)didSomeThing {//delegate method may call from any object
//how to get sender = someObj?
id sender = ??
}
....
//calling
[someObj didSomeThing];
...

Answer Source

You can't find out who is sender.

Every time you send message to object compiler transform it to:

objc_msgSend(receiver, selector, arg1, arg2, ...)

As you can see here is no way you can find out who is calling method except passing sender as parameter.

You can read more about it here in documentation

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download