The difference between an object and an NSObject

I am learning Objective-C, and as I can see, in some tutorials they use Object (imported from objc / Object.h), and in others I see using NSObject (imported from Foundation / NSObject.h), but what are the main differences between them?

Sincerely.

+7
object objective-c foundation nsobject
source share
3 answers

You must ignore Object.

Objective-C allows you to use multiple root classes. An object is a root class that precedes an NSObject. This is never what you would like to use. This is relevant only when something is already interacting with Object, so you have to deal with it. It is very rare.

An object does not implement, for example, -retain and -release .

+6
source share

Objective-C is just a language.

Cocoa frames use the base class NSObject as the root class for the hierarchy. Other implementations use their own root classes, in your case the Object class.

+6
source share

NSObject contains the entire Cocoa frame infrastructure. In other words, it conforms to several protocols that Object does not execute and will respond to certain methods that Object will not. In particular, see NSObject Class Reference and

+3
source share

All Articles