Lazy load usage and limitations in IOS development

Source: Internet
Author: User

1, many times in the development process, many controls and objects need alloc in order to improve the development efficiency so that lazy loading can be produced.

2, the following code interpretation:

1-(Nsmutablearray *) newsarr{2     if(!_newsarr) {3Self.newsarr = [Nsmutablearray array];//14 5 //2, _newsarr = [[Nsmutablearray alloc]init];6         7 //3, _newsarr = [Nsmutablearray array];8     }9 Ten     return_newsarr; One}

3, in the above code, I want a variable array newsarr, in the 1, 2, 3 of the wording,

3.1, the first kind of writing: Use point grammar setter to open up space for Newsarr;

3.2, the second kind of writing: use ALLOCD to set up the _newsarr of property to open up space

3.3, the Third Way: the use of convenient constructors, but also to obtain _newsarr, but its shortcomings are also obvious, when our newsarr need to reside in memory, there will be a crash problem;

Lazy load usage and limitations in IOS development

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.