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
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Hour 7. Declaring a Class in an Interface File > Exploring Class Hierarchies

Exploring Class Hierarchies

Except for NSObject, which is the root class for Cocoa, every class has a superclass. You can follow up the hierarchy until you get to NSObject.

Calling Superclass Methods

The methods of each superclass are available to a child class, but only one at a time. For example, consider the imaginary hierarchy shown here:

NSObject
NSView
 draw
MyAbstractView
 draw
MYView
 draw
MYSpecificView

The draw method is implemented in NSView, MyAbstractView, and MYView. If you instantiate MYView, the draw method in MYView is performed when you send a message to the instance of MYView. If you instantiate an instance of NSView, the NSView draw method is performed when you send a draw message to that instance. In terms of the architecture, each of the classes’ methods are separate.


  

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