iphone Technology architecture
1. Cocoa Touch Layer (mainly uikit frame)
Manage interface related user interaction events and behaviors such as: touch, swipe, swing, and provide basic program framework such as "Contact", "Picture", "Gravity Sensor", "camera", etc.
2. Media Layer
Provides a high-level program framework for sound, image, and advanced graphics and animation techniques.
3. OS Layer
Provides system-based services such as kernel, driver, and memory, threading, file system, network, process communication and other operating system interfaces.
iphone program startup process
Now we can open xcode,create a new Xcode project--iosapplication. Empty application, and then click Next, in the product Enter test in name and click Next to store the file directory.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/26/ED/wKiom1NvGYqi6aiSAACZ3zAZj7o343.jpg "title=" 1.png " alt= "Wkiom1nvgyqi6aisaacz3zazj7o343.jpg"/>
Presented in front of us is the file tree graph. In MAIN.M we can see the following code:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/26/ED/wKiom1NvDRjQecqAAAB9grPS8tQ349.jpg "style=" float: none; "title=" 2.png "alt=" Wkiom1nvdrjqecqaaab9grps8tq349.jpg "/>
This is the typical iOS boot code that joins arc, which tells us 3 things, creates a Autoreleasepool auto-free memory pool, calls the Uiapplicationmain () function, returns an int value, and finally frees the memory pool. The core here is Uiapplicationmain (), which accepts 4 parameters. The first two parameters are two arguments from the main function, and the latter two are the principal class and the delegate class, the primary class and the proxy class, respectively. If principal class is nil, the default is UIApplication. As long as the last two arguments are either not the Nil,uiapplicationmain () function, Gen creates the corresponding function class based on the parameter. It is not difficult to know if you have customized a uiapplication subclass (but not recommended), you need to say it as a third parameter to pass in.
When UIApplication is instantiated, it calls the application of the delegate interface :didfinishlaunchingwithoptions:. This function is a callback function belonging to Uiapplicationdelege, so the program needs a main class to implement this interface. Fortunately, XCODE5 has automatically created this class appdelegate for us. In AppDelege.h we can see the following code:
#import <UIKit/UIKit.h> @interface appdelegate:uiresponder <UIApplicationDelegate> @property (Strong, nonatomic) UIWindow *window; @end
It is obvious here that our appdelegate is inheriting Uiresponder and implementing the Uiapplicationdelegate interface, while affirming a uiwindow pointer _window, The parameters are strong and nonatomic respectively, these two parameters are now simply say, strong is for ARC technology to prevent deadlocks, nonatomic is non-atomic, and thread-related, we do not have to care about these two parameters, just a little bit of understanding.
Next in the. m file we can see application:didfinishlaunchingwithoptions: The specific contents of this function:
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions{ Self.window = [[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; Override point for customization after application launch. Self.window.backgroundColor = [Uicolor whitecolor]; [Self.window makekeyandvisible]; return YES;}
Inside about the specific operation with Uiwindows, we will refer later. Here is also a bit of understanding. The first sentence is to request memory and initialize the border to the main screen size, the second sentence to set the form background color is white, the third sentence to make the window visible and display on the screen.
So now we're talking about the program running on the iphone virtual machine to see the following image:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/26/ED/wKiom1NvHT6iYNkHAAMFvqixpIc310.jpg "title=" 3.png " alt= "Wkiom1nvht6iynkhaamfvqixpic310.jpg"/>
Yes, it's a white form, and there's nothing. It's been a long day and you've found that you didn't do anything. But don't be frustrated, for beginners to understand how the iOS program works is needed, and when we know how to launch an iOS program, we can add the content you want. The premise is that you need to know how it's started, and fortunately this article tells you how the iOS program starts. J Next Welcome to the world of iOS development!