Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocoa/Objective-C - Can i somehow see the implementation files?

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

like image 840
Mustafa Avatar asked Dec 03 '22 16:12

Mustafa


2 Answers

No, most (all?) of the Cocoa library implementations are only distributed in a compiled binary form. You could disassemble them, but that's probably against the Mac OS X EULA, and it also wouldn't help you understand them at all.

You could take a look at Cocotron, which is an open-source implementation of Cocoa. It won't be exactly the same, but at least for the core classes, it will be virtually identical.

like image 129
Adam Rosenfield Avatar answered Dec 26 '22 15:12

Adam Rosenfield


Many of the basic cocoa classes, like NSString and NSNumber, are implemented in core foundation and "toll-free bridged" to objective-c classes. Core foundation is a C (not ObjC) API and the source is available as part of the Darwin open-source project.

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

like image 29
dvenema Avatar answered Dec 26 '22 15:12

dvenema