Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inheritance, polymorphism, encapsulation in iOS? [closed]

What is exactly inheritance, polymorphism and encapsulation in iOS with example? Do iOS uses all this features? And how?

like image 819
Suraj SS Avatar asked Aug 11 '14 05:08

Suraj SS


1 Answers

The concept of inheritance brings something of a real-world view to programming. It allows a class to be defined that has a certain set of characteristics (such as methods and instance variables) and then other classes to be created which are derived from that class. The derived class inherits all of the features of the parent class and typically then adds some features of its own.

Please check This link: An Objective-C Inheritance Example

The word polymorphism means having many forms. Typically, polymorphism occurs when there is a hierarchy of classes and they are related by inheritance.

Objective-C polymorphism means that a call to a member function will cause a different function to be executed depending on the type of object that invokes the function.

Consider the example, we have a class Shape that provides the basic interface for all the shapes. Square and Rectangle are derived from the base class Shape.

Please check This link: An Objective-C Polymorphism Example

Encapsulation is an Object-Oriented Programming concept that binds together the data and functions that manipulate the data and that keeps both safe from outside interference and misuse. Data encapsulation led to the important OOP concept of data hiding.

Data encapsulation is a mechanism of bundling the data and the functions that use them, and data abstraction is a mechanism of exposing only the interfaces and hiding the implementation details from the user.

Please check This link: An Objective-C Data Encapsulation

like image 130
Nitin Gohel Avatar answered Sep 22 '22 22:09

Nitin Gohel