What are the two implicit parameters passed to every method by an object in Objective-c? Is it _cmd and id?
Objective C: Two implicit parameters passed to every method called by an object
495 views Asked by A J At
1
What are the two implicit parameters passed to every method by an object in Objective-c? Is it _cmd and id?
That is a good question, the short answer is: yes, two parameters are being implicitly passed. self of type id, and _cmd of type SEL.
to better understand it, here is what happens behind the method call.
a normal method call would be like:
that call gets translated/complied to:
to try it/use it your self.
1.#import<objc/message.h2. cast theobjc_msgSendmethod to an appropriate function pointer type before being used, like that.here is the function declaration
take a look at this documentation for further info.. objc_msgSend.
take a look also at this topic using objc_msgSend to call a Objective C function with named arguments for more info regarding other methods, specially Ken's answer.I hope that was helpful!