Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

In Objective-C, what is polymorphism?

0
10 Posted

In Objective-C, what is polymorphism?

0
10

Polymorphism is one of the pillars of OOP. In Objective-C, a perfect example of polymorphism uses the “id” keyword. As you know, the id keyword is a ‘general type’ variable that allows you to store any object of this: in this example, your code doesn’t need to know what a method returns; if you store it in an id variable you will be able to use it without problems. Basically, polymorphism means “many forms”: Any object could return anything and you can deal with it. It is easier to explain polymorphism with other languages (like C++), because their polymorphic features are more explicitly shown (like operator overloading or function overloading in C++).

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.