Is all "Core(Foundation,Data,Graphics,etc.)" written in C-like syntax?
I believe the question speaks for itself, and I know that to many of you this question might seem retarded. I just wonder if everything, in Objective-C, that starts with Core
is written in a plain C
.
My guess is "Yes, it is.", but I want to be sure for 100% ;)
Many thanks.
EDIT: Looking at the answers I now realise I should have asked about the syntax in Core
libraries.
Is it always C
like syntax: void myFunction(i开发者_运维百科nt num);
and not - (void) myFunction:(int) path;
?
So far one thing that I am not too fond of, in Obj-C, is mixing ()/dot/-> syntax with [] syntax. I think it really isn't elegant...
No offense, but the proper answer is "who cares"? (insert tongue in cheek)
Honestly, though, any system libraries can be written in pretty much whatever they want. There's probably a combination of Objective-C, C, C++, and assembler; less likely (but technically still possible) options include Pascal, Fortran, LOGO, or hand-assembled machine code.
If you want an example of the combinations of code in system libraries, take a look at the open-sourced Java libraries. You will see that the java.*
packages are written in a combination of Java and C; some ports may include assembly for parts.
As long as the interface is Objective-C compatible, that's all you really need to worry about.
Also, the only people who can answer that are probably at Apple, and probably aren't allowed to tell you.
It's written in "whatever" (a bit of ObjC, a lot of C, a bit of asm), but the key thing is that the interface it presents is pure C.
I'll note that Core Data and Core Image present ObjC interfaces though.
Yep it is - Appkit / UIKit is built on top of that, and they've done some tricks to make the interaction between ObjC and Core* to be very efficient (called "Toll-free Bridging")
It is Objective-C after all; the language is a very small layer of syntax on top of straight C with a runtime library to provide the dynamic behaviors.
Mixing C and Objective-C is a very oft encountered and natural part of the environment.
As others have said, the languages used to implement the various Core* frameworks is an implementation detail that should generally be of no concern. With that said, a good sized and growing chunk of CoreFoundation is written in Objective-C.
精彩评论