Cocoa / Objective-C - Can I see implementation files in any way?

I believe that I can learn something if I see implementation files (.m files). Is there a way to view the NSString.m or NSNumber.m files? and others? If I try to find these files using spotlight, I get nothing.

+4
source share
4 answers

No, most (all?) Cocoa library implementations are distributed only in compiled binary form. You can parse them, but it's probably against EULA Mac OS X, and it also won't help you understand them at all.

You can see Cocotron , which is an open source implementation of Cocoa. It will not be exactly the same, but, at least for the main classes, it will be almost identical.

+7
source

Many cocoa base classes, such as NSString and NSNumber, are implemented in the base and "free bridges" for objective-c classes. The core of the kernel is the C (non ObjC) API, and source is available as part of Darwin’s open source project.

So, to see how NSString or NSNumber are implemented under the hood, follow the link above and see CFString and CFNumber respectively (you will need an Apple developer account, but registration is free).

+6
source

I would suggest that they are already compiled into libraries.

I just checked my Mac quickly and could not find the NSString.m file. Do you use Xcode documentation? I believe that he has everything I need.

+1
source

All Articles