Changes

Jump to: navigation, search

Objective-C Dynamic Binding and Typing with the id Type

60 bytes added, 18:58, 24 November 2009
no edit summary
<hr>
<google>BUY_OBJC</google>
So far in this series of chapters covering object oriented programming with Objective-C we have focused exclusively on static class typing and binding. In this chapter we will look at concepts referred to as ''dynamic typing'' and ''dynamic binding'' and how the Objective-C ''id'' type is used in this context.
Polymorphism is the ability to have methods with the same name in different classes. For example both our SavingsAccount and CustomerInfo classes in the above examples have ''displayInfo'' methods. Whilst the code and resulting output displayed is different for each method they both ultimately achieve the same result (i.e. displaying the values assigned to the encapsulated instance variables). Polymorphism is a key concept in providing a consistent programming interface to the classes you create in your program. If all the classes have a method that performs a similar task then programming convention dictates that they should be given the same names. This helps both in writing code to work with objects and also with the use of dynamic binding.
 
<google>BUY_OBJC_BOTTOM</google>
<hr>

Navigation menu