Any automatic code generation tool is an enemy of beginners! This is the first time I learned the code generated by Microsoft Visual Studio's Wizzard. Now it's really funny to think about it. Someone who knows nothing about Event loop, MVC pattern, and basically knows nothing about the basic tool library of Windows programs can see the one generated by Wizzard, code over-encapsulated by MFC is a pure waste of time. After many years, I realized that automated tools and templates are actually used to improve the efficiency of skilled workers. For new users, they will only make things worse, once something goes wrong, the new employee doesn't know where to solve it!
Using XCode to develop apps on iOS devices will also help you generate a lot of source files and resources. You can compile and run them without having to change anything, starting from the main function, what happens when the application starts? The project generated by XCode contains a very simple main. m file, and the code in it is simple and simple (Apple recommends that you do not make any changes ):
#import <UIKit/UIKit.h>int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, nil); [pool release]; return retVal;}
Once the UIApplication is executed, only the proxy method of the application can be seen.
Didfinishlaunchingwitexceptions
Executed.
What does UIApplicationMain do?
First, it looks for Info. plist XML file. Note that the file name is fixed. If you look at your project, you will find that the file name is <Application name>-Info. plist. It doesn't matter. This is the Project setting. It will be copied to Info at the time of release. plist. You can click info in [Project]> [Edit Active Target "<Application name>. plist option to change which plist configuration file is used as the main configuration file for UIApplication. The UIApplication object reads the NSMainNibFile key in Info. plist and loads various properties of the UIApplication object based on the content of the nib file to which the key points.
Here we will talk about the nib file. Although this file is opened using interface builder, it contains not only the user interface, but also an object-C object database! The content stored in it is the attribute value of an object-C object. The theoretical point is an object serialized file, a program of the apple cocoa framework, you can use the content in this file to construct the preset object (not a class ).
Check the main nib file and you will see that XCode has implemented the UIApplicationDelegate protocol class for you. After you have created an object, the name is intuitive and you can check its connection attributes, you will find that it has been connected to the delegate attribute of the UIApplication object, which means that when the UIApplication object is built, its Delegate will be your application proxy class.
Needless to say later, connections have been established, and UIApplication objects call different proxy methods in sequence to start Event loop, the general infinite loop.
Finally, let's talk about acting for this thing ...... it is too mysterious. In fact, it is the interface in java or C #. It is estimated that object-C has appeared earlier and has not come up with such a proper name as interface.