IPhone development overview, iphone development overview

Source: Internet
Author: User

IPhone development overview, iphone development overview

### IPhone development overview

Sandbox Mechanism)
  • Sandbox in iOS is a security system that specifies that an application can only read files in a folder created for the application and cannot access content from other places. all non-code files are stored in this place, such as slice, sound, attribute list, and text files.
  • Every application is in its own sandbox.
  • You cannot freely access others' sandbox content across your sandbox.
  • The application must be authenticated to request or receive data.
Five States of an application
  • Not runing (Not running) program Not started
  • Inactive (Inactive) programs run on the foreground, but no events are received. The program usually stays in this state without event processing.
  • The Active program runs on the foreground and receives events. This is also a normal mode on the foreground.
  • Background (Background) programs are in the Background and can execute code. After most programs enter this state, they will stay in this state for a while. after the time is reached, it will be Suspended ). some programs can be in the Background state for a long time after special requests.
  • The sushortded (Suspended) program cannot execute code in the background. The system will automatically change the program to this State and no notification will be sent. When Suspended, the program will remain in the memory, and when the program memory
Application Status Lifecycle

This method is called when the iOS app is loaded and the app is almost ready to run. We usually need to use this method to complete app initialization and final settings. this method is called before the window and UI of the app.

- (BOOL)application:(UIApplication *)application didFinishLanunchingWithOption:(NSDictionary *)LaunchOptions

When the application is about to enter the inactive state for execution, during this period, the application does not accept messages or events, such as phone calls or screen locks. It is usually implemented in this method: stop timer and other periodic tasks, stop any running requests, pause video playback, pause it if it is a game, reduce the Frame Rate of OpenGL ES, scrape any distribution queue and unimportant operation Queue (you can process network requests or other time-sensitive background tasks ).

- (void)appliWillResignActive:(UIApplication *)application

When the application enters the active state for execution, this state is just the opposite of the method above. You need to re-start the task, for example, re-start timer, continue to distribute the queue, and improve the Frame Rate of OpenGL ES. however, the game must be paused and cannot start automatically.

- (void)applicationDidBecamActive:(UIApplication *)appliction

Called when the program is pushed to the background. so to set the background to continue running, you can set it in this function. this method needs to be implemented: to save user data or status information, all files or information not written to the disk, and write it to the disk at the end of the process, because the program may be killed in the background, release the memory as much as possible.

- (void)applicationDidEnterBackground:(UIApplication *)application

It is called when the program returns the program to the foreground from the background, which is the opposite of the method above.

- (void)applicationWillEnterForeground(UIApplication *)application

When the program is about to exit, it is usually called to save data and clean up before exiting. This requires setting the key value of UIApplicationExitsOnSuspend.

- (void)applicationWillTerminate:(UIApplication *)application
Main Function
  • The main function is the entry to program startup. in iOS apps, the main function is minimized, and its main work is handed over to the UIKit framework.
# import <UIKit/UIKit.h># import "PNAppDelegate.h"int main(int argc, char * argv[]){    @autoreleasepool{        return UIApplicationMain(argc,argv,nil,NSStringFromClass([PNAppDelegate class]));    }}

The UIApplicationMain function has four functions. You do not need to change these parameter values. However, we need to understand how these parameters and programs start: the argc and argv parameters contain the startup time brought by the system. the third parameter determines the name of the main application class. This parameter is specified as nil, so that UIKit uses the default UIApplication class to create an object. the fourth parameter is the program-defined proxy class name, which is responsible for interaction between the system and code. it is generally automatically generated when a new project is created in Xcode.
In addition, the UIApplicationMain function loads the file on the main interface of the program. Although this function loads the interface file, it is not stored on the windows of the application.

It is important to understand the following three things that UIApplicationMain does:
1. Create a UIApplication object based on the third parameter.
2. Create the application's delegate according to the fourth parameter and set the delegate.
3. Set the main event loop, including the application's run loop, and start to process the event.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

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.