- Static Typing VS Dynamic Typing
- Code example with Objective-C id type
- Dynamic Binding
<Static Typing VS Dynamic Typing>
Static typing - we have provided enough information for compiler to check for errors during the compilation process.
Dynamic typing - allows us to declare a variable that is capable of storing any type of object, regardless of its class origins.
This is achieved using the Objective- id type.
<Code example with Objective-C id type>
id object1;
object1 = [[savingAccount alloc] init];
[object1 setAccount: 455654545];
[object1 setBalance: 1234.56];
object1 = [[CustomerInfo alloc] init];
[object1 displayInfo];
<Dynamic Binding>
Dynamic binding means that allows users declare the variable with id type without prior knowledge of the type of object currently assigned to the variable.
No comments:
Post a Comment