Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since Objective-C is a derivative of C, much of the internals are similar (which is why you can mix C\C++ code in with Objective-C)). As such, when both compile into executables, they work off of similar systems. This is also why Objective-C is compiled by gcc or Clang.</p> <p>With that in mind, what happens when you compile? All of your C code gets converted into Assembly\machine code (since Assembly is just a mnemonic version of machine code). Assembly is on a lower level than Java; the CPU just runs through it and executes each individual instruction sequentially. The <code>main()</code> function in C languages is where the compiler 'knows' where the instructions start at. After you do all of your declarations, the <code>main()</code> function gets jumped to with an instruction called '<code>jmp</code>'.</p> <p>So what happens when you compile in Xcode and launch? First, gcc/Clang converts the code into Assembly\machine code. Second, Xcode loads the binary file into memory. Third, Darwin (OS X or iOS, or any OS for that matter) recognizes that this is an executable area of memory, and starts from the top of the instruction set and runs through each instruction.</p> <p>To answer your question, the <code>main()</code> function is started by the CPU. This is different than Java, which has a platform-independent instruction set that is 'emulated' in the JVM.</p> <p><a href="https://stackoverflow.com/questions/823138">This</a> question has a great answer which explains how the <code>main()</code> function gets translated into Assembly code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload