I know that Objective-C uses dynamic binding for all method calls. How is this implemented? Does objective-c “turn into C code” before compilation and just use (void*) pointers for everything?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Conceptually, what is going on is that there is a dispatcher library (commonly referred to as the Objective C runtime), and the compiler converts something like this:
into
And then the runtime deals with all the binding and dispatch, finds an appropriate function, and calls it with those args. Simplistically you can think of it sort of like a hash lookup; of course it is much more complicated that then in reality.
There are a lot more issues related to things like method signatures (C does not encode types so the runtime needs to deal with it).