Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

2. Objective-C > Subclassing an Objective-C Class

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

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial