mirror of
https://github.com/NohamR/knowledge-kit.git
synced 2026-05-25 04:17:17 +00:00
docs: 批量博文
This commit is contained in:
16
Chapter1 - iOS/1.61.md
Normal file
16
Chapter1 - iOS/1.61.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# App 启动时间优化
|
||||
|
||||
在看 App 启动时间优化之前先看2个方法: **load** 和 **initialize**。
|
||||
|
||||
load
|
||||
> Invoked whenever a class or category is added to the Objective-C runtime; implement this method to perform class-specific behavior upon loading.
|
||||
当一个类或者它的分类被加载到 Objective-c 的 runtime 中的时候会出发 load 方法。可以实现这个方法去执行一些类特定的行为。
|
||||
|
||||
initialize
|
||||
> Initializes the class before it receives its first message.
|
||||
当一个类接收到第一条消息的时候会初始化。
|
||||
|
||||
load 方法会在类被加载到 runtime 的时候调用。且父类的 load 方法比子类先执行。load 方法只会执行1次。
|
||||
initialize 方法会在第一次收到消息的时候调用。父类的 initialize 方法比子类先执行。假如有 Person 类,还有一个子类 children。子类第一次收到消息的时候会先调用父类的 initialize,然后调用子类的 initialize,如果子类没有实现 initialize 那么父类的 initialize 会执行多次。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user