iOS Development private variable use selection for private properties

Source: Internet
Author: User

Private member variables and private properties can be declared in. m files

Property has done three things: Create an instance variable that starts with an underscore, generate a getter, and setter method.

Member variables: create only instance variables;

The property automatically generates the Setter,getter method, sometimes generating some useless methods, causing the program's IPA volume to be too large.

Use member variables to run faster.

Use property when development uses lazy loading (variables are loaded when needed)

-(Nsmutablearray *) Imagesarr

{

if (_imagesarr = = nil) {

_imagesarr = [Nsmutablearray array];

}

return _imagesarr;

}

Recommendation: When you do not need to use lazy loading, directly in the. m file to create instance variables using _XX, to reduce the volume of IPA, improve the speed of the program, to minimize the mix of the situation.

iOS Development private variable use selection for private properties

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.