CHAPTER 18

image

Inheritance

When you want to code a new class that shares most of the properties and methods of another class, you can use inheritance. A class that is inherited from another class takes on all the properties and methods of the superclass.

You use inheritance when you want to leverage the work that has already been completed and then add more properties and methods to customize the new class. This pattern gives us code reuse.

You saw examples of inheritance in Chapter 16: when you created the Project class, you inherited NSObject. This gave Project all the methods and properties of NSObject.

A more interesting application happens when ...

Get Objective-C Quick Syntax Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.