Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do all objects inherit from NSObject?

I know you can implement using Object class but is there any in Apple's Objective C?

like image 953
Sajal Dutta Avatar asked Feb 11 '12 01:02

Sajal Dutta


2 Answers

Just about every Cocoa class inherits from NSObject. Even the slightly esoteric Block objects, whose class tree isn't public, have NSObject at the root.

The only other root class that is publicly known in Cocoa is NSProxy, though it does conform to the NSObject protocol, which allows it to act in many ways like any other Cocoa object.

like image 81
jscs Avatar answered Sep 23 '22 03:09

jscs


In theory, it is possible to define a class that does not inherit from NSObject.

But in practice it is so difficult that no-one ever bothers to do it. NSObject does quite a lot of very nice stuff for you.

like image 42
Abhi Beckert Avatar answered Sep 22 '22 03:09

Abhi Beckert