Comments (1)
我的理解是这样:
原来对象创建的时候,可能在 init 系列方法就做了一些初始化工作(打开文件,绑定端口,初始化成员变量等等),如上面的代码的例子是初始化 _dateFormatter。使用 lazy initialization 的时候,只有你第一次调用的时候 -dateFormatter 方法,才会做这些初始化的工作。
假如这些初始化工作很消耗性能,或者有一些问题,那么这些问题在对象初始化的时候就能被创建出来。但是使用 lazy initialization 后,实际的初始化工作是在后续某个执行过程中,才会做这些操作。那么你去测试性能或者用 Instrument 这些工具,就要去追踪后面的执行过程什么时候会调用到这个地方了,而不是单纯看哪个对象创建的时候比较耗时。
from objc-zen-book-cn.
Related Issues (15)
- 第六章没有翻译完 HOT 2
- Gitbook链接 HOT 1
- 是不是太着急了 HOT 1
- 翻译错误 HOT 11
- 关于 Secondary initializer 段落的翻译问题 HOT 15
- practice HOT 2
- GitBook中文版的封面设计 HOT 1
- 常量extern的写法在Xcode7中编译不通过 HOT 1
- 翻译错误 HOT 1
- block循环应用那里有个错误??
- 一个小错字 HOT 1
- 关于weekSelf和strongSelf中的问题 HOT 2
- 关于"重载"和"重写" HOT 2
- It's interesting to understand why do we need to set the value of `self` with the return value of `[super init]` and what happens if we don't do that. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from objc-zen-book-cn.