The answer to this question may be obvious but I need to ask it to be certain:
Do all objective c classes share a common default base class when a base class is not explicity defined in the class definition?
No, if you do not explicitly define a super class in the class definition you are creating a root class.
From Cocoa Core Competencies:
A root class inherits from no other class and defines an interface and behavior common to all objects in the hierarchy below it. All objects in that hierarchy ultimately inherit from the root class. A root class is sometimes referred to as a base class.
The root class of all Objective-C classes is NSObject
, which is part of the Foundation framework. All objects in a Cocoa or Cocoa Touch application ultimately inherit from NSObject. This class is the primary access point whereby other classes interact with the Objective-C runtime. It also declares the fundamental object interface and implements basic object behavior, including introspection, memory management, and method invocation. Cocoa and Cocoa Touch objects derive the ability to behave as objects in large part from the root class.
The Foundation framework defines another root class, NSProxy
, but this class is rarely used in Cocoa applications and never in Cocoa Touch applications.
See also:
Why subclass NSObject?
What use cases are there for defining a new root class?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With