views:

440

answers:

5

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.

+1  A: 

I would guess they are already compiled into libraries.

I just did a quick check on my mac and could not find a NSString.m file as well. Are you utilizing Xcode's documentation? I find it has most everything I need.

J.J.
+5  A: 

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.

Adam Rosenfield
+1  A: 

Also worth looking at the mySTEP sources.

This helped me when doing something that subclassed NSMatrix some time ago.

Matthew Schinckel
+5  A: 

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).

dvenema
A: 

Thanks guys.

Mustafa