Lazy loading, also known as deferred loading, means that during the development process, the resources are not loaded at the start of the program, but are created and loaded when they are used.
iOS devices have limited memory, and if you load all the resources (tablets, data, audio loads, etc.) at the start of the program, it will take up a lot of memory on your device.
--1, custom controls
For custom control properties, you must be a strong type to prevent the control from being destroyed after it has been created because there is no strong pointer pointing.
Such as:
// Default expression content @property (nonatomic,strong) Shemotionlistview * Defaultlistview;
--2, lazy loading in the getter method for attributes
Such as:
-(Shemotionlistview *) defaultlistview{ if (! _defaultlistview) { = [[Shemotionlistview alloc] init]; *path = [[NSBundle mainbundle] Pathforresource:@ "emotionicons/default/info.plist" Oftype:nil]; = [shemotion objectarraywithkeyvaluesarray:[nsarray arraywithcontentsoffile:path]; } return _defaultlistview;}
Lazy loading is when there is a certain need, and then instantiated into memory.
[Self addSubview:self.recentListView];
Lazy loading the first time the getter method is called, the control is empty before the instantiation is loaded into memory.
The benefits of lazy loading are:
--You do not have to write all the code of the created object in the Viewdidload method, the code is more readable.
--Each property's Getter method is responsible for the respective instantiation processing, and the coupling degree between the code is correspondingly reduced.
--only when resources are really needed, will they be created and loaded, saving memory resources.
01-Lazy Loading