iOS lazy loading

Source: Internet
Author: User

Bloggers have been developing iOS for some time (novice ha), often in watching the blog of the Great God to learn things, but also decided to write their own blog, sharing ideas, but also hope that you crossing greatly put forward their views ha.

When setting the properties of a class (with @property), the simple point can be constructed using his own set method.

-(UILabel *) label

{

if (_label = = nil)

{

_label = [[UILabel alloc] initwithframe:cgrectmake (0, 100, 414, 40)];

_label.backgroundcolor = [Uicolor Lightgraycolor];

}

return _label;

}

On the view you need to add, for example in Viewdidload, add

[Self.view AddSubview:self.label];

His self. will automatically call the Set method, so in the Set method is used _label, if it is Self.label will appear badaccess

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.