Lazy Loading
Lazy Loading--also known as deferred loading--is loaded when needed (low efficiency, small memory footprint). The so-called lazy load, write is its get method.
Note: If it is lazy loading, it is important to be aware of whether there is already, if not then to instantiate
Why Use Lazy Loading: (1) You do not have to write all the code of the created object in the Viewdidload method, the code is more readable
(2) Each control's getter method is responsible for the respective instantiation processing, the code is independent of each other, loosely coupled
notation: In the. h file declaration @property (Nonatomic,retain) Cllocationmanager (Because of the Cllocationmanager class, the. h file should also be imported into its frame #import < corelocation/corelocation.h>)
@property (Nonatomic,retain) Cllocationmanager *mymanager;ymanager;
Inside the. m file
Lazy load, get method, call again when needed
-(Cllocationmanager *) mymanager{
if (!_mymanager) {
_mymanager =[[cllocationmanager Alloc]init];
How many meters update once
_mymanager.distancefilter = 10;
Degree of precision
_mymanager.desiredaccuracy =kcllocationaccuracybest;
_mymanager.delegate =self;
}
return _mymanager;
}
ios-Lazy Loading