iOS文档--About the App Launch Sequence(app 启动的初始化步骤)
Article
About the App Launch Sequence --关于app的启动序列
Learn the order in which your custom code is executed at launch time.
--理解你的代码在app启动期的执行顺序
Overview --概览
Launching an app involves a complex sequence of steps, most of which UIKit handles automatically. During the launch sequence, UIKit calls methods of your app delegate so that you can perform custom tasks. Figure 1 illustrates the sequence of steps that occur from the time the app is launched until it is considered initialized.
--启动app需要一系列复杂的步骤,其中大部分是UIKit自动处理的。在启动序列期间,UIKit会调用app delegate的方法,所以您可以在这些方法中执行自定义任务。图1展示了从app启动完成初始化的一系列步骤。
Figure 1
The app launch and initialization sequence --app启动期间的初始化步骤:
-
The app is launched, either explicitly by the user or implicitly by the system.
--app可以由用户显式地启动,也可以由系统隐式地启动 -
The Xcode-provided
main
function calls UIKit'sUIApplicationMain(_:_:_:_:)
function.
--”xcode提供的main
函数“调用UIKit的UIApplicationMain(_:_:_:_:)
方法。 -
The
UIApplicationMain(_:_:_:_:)
function creates theUIApplication
object and your app delegate.
--UIApplicationMain(_:_:_:_:
方法创建UIApplication
对象和app delegate对象 -
UIKit loads your app's default interface from the main storyboard or nib file.
--UIKit从 main storyboard 或nib文件加载app的默认界面 -
UIKit calls your app delegate's
application(_:willFinishLaunchingWithOptions:)
method.
--UIKit调用app delegate的application(_:willFinishLaunchingWithOptions:)
方法 -
UIKit performs state restoration, which calls additional methods of your app delegate and view controllers.
--UIKit执行状态恢复进程,状态恢复进程会调用app delegate和vc上的附加方法。 -
UIKit calls your app delegate's
application(_:didFinishLaunchingWithOptions:)
method .
--UIKit调用app delegate的application(_:didFinishLaunchingWithOptions:)
方法
When initialization is complete, the system uses either your scene delegates or app delegate to display your UI and manage the life cycle for your app.
--当初始化完成时,系统会使用你的scene delegate或者app delegates对象来显示你的UI,还有管理你的app的生命周期。
See Also
Launch Time
Performing One-Time Setup for Your App
Ensure that your app environment is properly configured.
Preserving Your App's UI Across Launches
Return your app to its previous state after it is terminated by the system.