O'Reilly logo

iOS Programming: The Big Nerd Ranch Guide by Joe Conway, Aaron Hillegass

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

Subclassing an Objective-C Class

Classes, like NSMutableArray, exist in a hierarchy, and every class has exactly one superclass – except for the root class of the entire hierarchy: NSObject (Figure 2.8). A class inherits the behavior of its superclass, which means, at a minimum, every class inherits the methods and instance variables defined in NSObject.

As the top superclass, NSObject’s role is to implement the basic behavior of every object in Cocoa Touch. Three of the methods NSObject implements are alloc, init, and description. (We sometimes say description is a method on NSObject and mean the same thing.)

Figure 2.8  Class hierarchy

Class hierarchy

A subclass ...

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