1

我知道所有加载类的信息都是在启动时收集的。但是我找不到任何关于它是如何完成的信息,以及与普通 C 程序的启动例程相比,Objective-C 启动例程的外观如何。

我只是想知道从这一点开始在 Objective-C 中添加了什么。Objective-C 程序是带有一些附加功能的 C 程序,还是结构完全不同?

4

1 回答 1

1

You should take a look at this article from Cocoa with Love: http://cocoawithlove.com/2008/03/cocoa-application-startup.html , which gives a good overview.

However, if you really want to know what's going on, it's going to be a bit of a dig, but you can look at the source to the runtime at http://opensource.apple.com/ . Look for the objc4* project inside of whichever OS you are interested in. Look to objcrt.c for the top of the initialization chain.

You asked two discrete questions in your original post: what the startup routine looks like (which is covered in the runtime) and "Is Objective-C program a C program with some additions". The answer to the latter is yes, it is a C program with some additions, in the same manner as C++. And, like C++, it contains some pretty significant additions to the runtime.

于 2012-05-29T11:32:45.620 回答