UIApplicationDelegate

UIApplicationDelegate官方文档

1.定义

一组用于管理应用程序共享行为的方法。

2.声明

1
protocol UIApplicationDelegate

3.概况

  1. 管理app的共享行为。
  2. UIApplication一起管理与系统的交互行为。
  3. 在app启动周期的早期就会创建app委托对象,因此一直存在。

用来处理一下任务:

  • 初始化app的中心数据结构
  • 配置app的场景
  • 响应来自app外部的通知
  • 响应的事件是以app本身为目标的,而不是以场景、视图、视图控制为目标
  • 在启动时注册必需的服务

4.IOS12及更低版本的生命周期管理

在IOS12及更低版本是使用app delegate来管理主要的生命周期事件,主要是当程序进入前台时或移动到后台时更新app状态。

5.Topics

5.1 Initializing the App

通知委托对象,启动操作已开始,但是状态存储还没发生。

1
2
3
func application(UIApplication, 
willFinishLaunchingWithOptions: [UIApplication.LaunchOptionsKey : Any\]?)
-> Bool

通知委托对象,启动处理已完成,并且app已准备好运行

1
2
3
func application(UIApplication, 
didFinishLaunchingWithOptions: [UIApplication.LaunchOptionsKey : Any\]?)
-> Bool

5.2 Configuring and Discarding Scenes

5.3 Responding to App Life-Cycle Events

5.4 Responding to Environment Changes

5.5 Managing App State Restoration

5.6 Downloading Data in the Background

5.7 Handling Remote Notification Registration

5.8 Continuing User Activity and Handling Quick Actions

5.9 Interacting With WatchKit

5.10 Interacting With HealthKit

5.11 Opening a URL-Specified Resource

5.12 Disallowing Specified App Extension Types

5.13 Handling SiriKit Intents

5.14 Handling CloudKit Invitations

5.15 Managing Interface Geometry

5.16 Providing a Window for Storyboarding

5.17 Deprecated Symbols

5.18 Instance Methods

6.Relationships

6.1 Inherits From

6.2 Inherited By

0%