I am having hard time to understand what is difference between dynamic binding Vs dynamic typing in Objective C. Can someone explain this ?
I am having hard time to understand what is difference between dynamic binding Vs
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.
Dynamic typing in Objective-C means that the class of an object of type
idis unknown at compile time, and instead is discovered at runtime when a message is sent to the object. For example, in the following code, the class offooisn’t known until we attempt to send the messagecomponentsSeparatedByString:.If instead of using the
iddata type we had done the following……then we’d be using static typing rather than dynamic typing.
Dynamic binding means that the compiler doesn’t know which method implementation will be selected; instead the method implementation is looked up at runtime when the message is sent. It basically helps us with Polymorphism. So
results in invoking a different method implementation if, for example,
foois an instance ofNSArrayrather than an instance ofNSString.