iOS Review Note 16: Apply startup process and engineering structure

Source: Internet
Author: User

A new project
Open Xcode->new->project->ios->single View application-> Next, enter project name, next, select Path->create


Two start-up process
1 Loading programs into memory
2 Create a uiapplication in the main function
3 Creating Appdelegate
4 start main loop, listen for events
5 Creating UIWindow, setting the active window
7 Load the Info.plist file, read the main storyboard file
8 Loading the storyboard file, creating the Viewcontroller
9 Set the Viewcontroller you created above Rootviewcontroller
10 display UIWindow, Rootviewcontroller view is displayed in UIWindow


Three codes
Application.h
...//If nil is specified for Principalclassname, the value of Nsprincipalclass from the info.plist is used. If there is no//nsprincipalclass key specified, the UIApplication class is used. The delegate class would be instantiated using init. Uikit_extern int uiapplicationmain (int argc, char *argv[], nsstring *principalclassname, NSString *delegateclassname); ...



Main.m
#import <UIKit/UIKit.h> #import "AppDelegate.h" int main (int argc, char * argv[]) {    @autoreleasepool {        Return Uiapplicationmain (argc, argv, Nil, Nsstringfromclass ([Appdelegate class]);    }}



AppDelegate.h
#import <UIKit/UIKit.h> @interface appdelegate:uiresponder <UIApplicationDelegate> @property (Strong, nonatomic) UIWindow *window; @end




Appdelegate.m
#import "AppDelegate.h" @interface appdelegate () @end @implementation appdelegate-(BOOL) Application: (UIApplication *) Application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {//Override point for customization after app    Lication launch. return YES;} -(void) Applicationwillresignactive: (uiapplication *) application {//Sent when the application was about to move from a Ctive to inactive state. This can occur for certain types of temporary interruptions (such as a incoming phone call or SMS message) or when the US    Er quits the application and it begins the transition to the background state. Use the This method to the pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should with this method to pause the game.} -(void) Applicationdidenterbackground: (uiapplication *) application {//Use the method to release shared resources, SA ve user data, invalidate timers, and store enough application state information to restore your application To It is terminated later. If your application supports background execution, this method is called instead of Applicationwillterminate:when the User quits.} -(void) Applicationwillenterforeground: (uiapplication *) application {//called as part of the transition from the back Ground to the inactive state; Here's can undo many of the changes made on entering the background.} -(void) Applicationdidbecomeactive: (uiapplication *) application {//Restart any tasks this were paused (or not yet STA rted) While the application was inactive. If the application is previously in the background, optionally refresh the user interface.} -(void) Applicationwillterminate: (uiapplication *) application {//called when the application was about to terminate. S Ave data if appropriate. See also Applicationdidenterbackground:.} @end


ViewController.h
#import <UIKit/UIKit.h> @interface Viewcontroller:uiviewcontroller@end



Viewcontroller.m
#import "ViewController.h" @interface Viewcontroller () @end @implementation viewcontroller-(void) viewdidload {    [ Super Viewdidload];    Do any additional setup after loading the view, typically from a nib.} -(void) didreceivememorywarning {    [super didreceivememorywarning];    Dispose of any resources the can be recreated.} @end



iOS Review Note 16: Apply startup process and engineering structure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.