ios-Lazy Loading

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.