Is the NSObject class part of the Objective-C runtime library today (instead of being a Foundation component)?

Looking at the Mac OS X version 10.8 of the source code for the Objective-C library , I noticed that it got NSObject.mm . As the name implies, he received an implementation of the class NSObject, as well as a built-in pool of auto-calculations and retained the functions of counting.

However, versions of the ObjC runtime library before Mountain Lion did not implement the class NSObject(they did not have a file NSObject.mm, as you can see on Mac OS X 10.7 Objective-C, the source code of the runtime library , for example).

Does this mean that the class is NSObjectnow part of the Objective-C runtime library instead of being a component of the Foundation library? If so, why? Should linking with the entire Foundation library (c -framework Foundation) be avoided when subclassing NSObject?

+5
source share
2 answers

You can see what part of a particular library the nm (1) tool uses.

If you run this on libobjc, you will find that NSObject is essentially provided by libobjc:

% nm /usr/lib/libobjc.dylib | grep -F NSObject
0000000000021688 t +[NSObject _isDeallocating]
0000000000021674 t +[NSObject _tryRetain]
0000000000021780 t +[NSObject allocWithZone:]
000000000002176e t +[NSObject alloc]
0000000000021699 t +[NSObject allowsWeakReference]
0000000000021712 t +[NSObject autorelease]
0000000000020fa6 t +[NSObject class]
000000000002115a t +[NSObject conformsToProtocol:]
00000000000217ea t +[NSObject copyWithZone:]
00000000000217e6 t +[NSObject copy]
000000000002178d t +[NSObject dealloc]

("t" means that the symbol is provided by this library, "u" means that the symbol is undefined, which means that this library uses it, but it should appear from somewhere else.)

, NSObject; Lion CoreFoundation.framework.

, . , ; , NSObject - .

+7

NSObject Foundation. ( , , ). , NSObject C- Objective-C , , Foundation , - . C ObjC, , .a >

NSObject, , - , , libDispatch/libXPC ObjC ( ObjC ) Core Foundation , - .

( @Catfish_Man)

+3

All Articles