O'Reilly logo

Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android by Michael Eierman, Jakob Iversen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Inheritance and Protocols

One of the important concepts of object-oriented programming is inheritance, which allows for creating simpler and more efficient code by allowing one class to inherit all the properties of another class. This gives the benefit of polymorphism, where a variable can be declared to hold a particular type in the code, but at runtime, any object declared of that class or any of its subclasses can be assigned to the variable.

Inheritance in Objective-C works exactly like it does in Java and C#. Only the syntax is slightly different. To specify inheritance, you add a colon and the super class name to the @interface line in the .h file. For instance, the Book class you created earlier could form the basis for a PhotoBook class, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required