1. Lazy Load Basic
Lazy Loading--also known as deferred loading--is loaded when it is needed (inefficient, small memory footprint). The so-called lazy load, write is its getter method. The popular point is that in the development, when the program needs to use resources. The resource is not loaded when the program is started, only when it is run when some resources are needed.
We know that the memory of iOS devices is limited, and if you load all the resources that will be used in the future after the program starts, it is possible to deplete the memory of the iOS device. These resources such as a lot of data, pictures, audio and so on, so we use lazy load must be careful to determine whether there is already, if not then to instantiate
2. The advantages of using lazy loading:
(1) Do not have to write all the code to create the object in the Viewdidload method, the code is more readable
(2) Each control's getter method is responsible for the respective instantiation process, the code is independent of each other strong, loose coupling
(3) Save the memory resources only when the resource is really needed, then load it.
3. code example
For example, the application of the login interface is usually a combination of lable and TextField we customize a Ltview class containing titlelable attributes and TextField attributes
Then we can complete the lazy loading (lazy load) mode by overriding the property's Getter method, using lazy loading can encapsulate the code according to the module, increase the flexibility of the class, and save memory usage for a certain period of time, for the current Ltview, Using lazy loading indicates that I provide two views, and if so, order calls getter methods can display the child view, and if not, Ltview is an empty view
Reminder: This is what apple advocates. In fact, many parts of Apple's iOS system use lazy loading, such as the creation of a controller's view.