Bhagabata
Bhagabata

Reputation: 473

Who is the base class of NSObject in Objective-C?

I heard NSObject is the main parent class where all classes are derived. But my question is there any class existing where NSObject class is being derived?

Upvotes: 0

Views: 2091

Answers (3)

surendrasheoran
surendrasheoran

Reputation: 3

NSObject and NSProxy are two root classes in Cocoa. NSProxy is rarely used in Cocoa applications and never in Cocoa Touch applications.

Upvotes: 0

user3182143
user3182143

Reputation: 9609

Apple Documentation Says

NSObject is the root class of most Objective-C class hierarchies. Through NSObject, objects inherit a basic interface to the runtime system and the ability to behave as Objective-C objects.

Also Root Class Says

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.

Upvotes: 1

CRD
CRD

Reputation: 53010

NSObject is the primary, but not only, root class of Cocoa. A root class does not have a base class, it is the root of class hierarchy.

Another Cocoa root class is NSProxy.

Note: The above are all root classes of Cocoa, Apple's framework, the Objective-C language itself does not define any root classes at all - this differs from languages like Java and C# where there is a language defined root class or classes.

Upvotes: 2

Related Questions