Day19 ios common files

Info.plist file

The configuration file of the program running cannot be deleted (the infoplist file is modified, the simulator application needs to be deleted, and the program needs to be cleaned).

bundledisplayname: program name

bundleID: Listing ID

bundleversionstring: official version

bundleversion: internal version

mainstoryboard: The storyboard loaded by the program startup

InfoPlist.strings

Related to Info.plist localization

pch

It is a header file that can be shared and accessed by all source files in the project, and is generally used to define some global macros

This macro is defined by default in the .m and .mm files in the __OBJC__ project. If the global header file or macro is only used in the .m and .mm files, it is written in this macro. Define Log in this macro, so it is convenient to comment out all Log when publishing

#define Log(...) NSLog(__VA_ARGS__)

When posting, comment out this sentence as follows

#define Log(...) // NSLog(__VA_ARGS__)

In summary, it can be written as

#ifdef DEBUG

#define Log(...) NSLog(__VA_ARGS__)

#else

#define Log(...) 

#endif

UIApplication

Each application has its own UIApplication, singleton mode, the same as in Android UIApplication *sharedApplication = [UIApplication sharedApplication]; This singleton can be obtained, and the first object created when the program starts is the UIApplication object

APPDelegate

When the app is interrupted, some system events will be generated, and UIApplication will notify its delegate to handle these events, including

1. Application life cycle events

applicationdidFinishLaunchingWithOptions (called when the app is started)

applicationWillResignActive (called when focus is lost)

2. System events (calling, clicking home, etc.)

applicationDidEnterBackground (called when the app enters the background, generally used to save the data and status of the application)

applicationDidEnterForground (called when the app enters the foreground, generally used to restore the data and status of the application)

3. Memory warning

applicationDidReceiveMemoryWarning (called when the app receives a memory warning)

Program startup process

1. Execute the main function

2. UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])));//Number of parameters passed in by the user, parameters passed in by the user, NSString *principalClassName: Specify the application class name, which must be UIApplication or a subclass, if it is nil, the default is UIApplication, NSString *delegateClassName: specifies the proxy class of the application, which must comply with the UIApplicationDelegate protocol

3. According to the last two parameters, create UIApplication object and object proxy

4. Open the event loop (queue) and listen to system events

UIWindow

It is a special UIWindow. There is only one main UIWindow in an app. The first view control created by the program startup is UIWindow, then the view of the controller is created, and then the view of the controller is added to the UIWindow. When you create an empty project, you can see the startup code in the APPDelegate.

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

self.window.backgroundColor = [UIColor whiteColor];

set root controller

(see UINavigationController)

UIWindow becomes the main window

[self.window makeKeyAndVisible];

UINavigationController

Navigation controllers manage child controllers through stacks 

1. Create a Navigation Controller

UINavigationViewController *nav = [[UINavigationViewController alloc] init];

2. Set the root controller, this controller will start

self.window.rootViewController = nav;

3. Add the first created controller to the navigation controller

OneViewController *one = [[OneViewController alloc] init];

[nav pushViewController:one animated:YES];

or

OneViewController *one = [[OneViewController alloc] init];

UINavigationViewController *nav = [[UINavigationViewController alloc] initWithRootViewController:one];

self.window.rootViewController = nav;

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326939833&siteId=291194637