Set method for IOS Properties _string = string; What do you mean?

Source: Internet
Author: User

      Find yourself particularly tragic recently, probably because the foundation did not play well, directly learn how to build a house, but the foundation has been revised, so the house is built according to the foundation of the load-bearing wall Ah, some simple partition wall, is also the ground message. On the contrary, it is the basis of some foundation, and is always carried to the Taiwan case.       Today, like write a property: @property (Nonatomic, assign) Nsinteger Selectedindex;set method:-(void) setSelectedIndex: (Nsinteger) selectedindex {     _selectedindex = selextedindex;     }       Front that _selectedindex really can not categorization malleability say what is the meaning, this problem, will not have the interviewer asked me, but I will ask myself, because where I do not, I understand, bored, still want to figure out clearly.       looked up, there is no relevant information, may be because the search term is inaccurate, but also found some information, it is helpful to me. _selectedindex is automatically generated by the system, as long as the @property form of the property is written, the _selectedindex variable will be automatically generated, then assigned to his value, selectedindex we know, Are foreign values that are assigned to this attribute, such as Self.selectedindex = 5;      Here's to say, Self.selectedindex is called the SelectedIndex set method, you call the set method, you want to assign a value, then you want to assign this value is 5;      then you can not give the system that _ SelectedIndex is assigned, but you use the SelectedIndex property outside of the set method, this value has no value. I'll try. Very happy, because the fact that it is true, if you do not give the value assigned to SelectedIndex and then to the system for our auto-created _selectedindex, then other places to use, there will be no value. Regardless of whether you use Self.selectedindex or use _selectedindex, there is no value, of course, bool type initial value 1 or Yes,nsThe integer type has an initial value of 0, but this value is not assigned to you.       From this point of meaning, _selectedindex means that the system has automatically created a global variable for us to use outside of the set method, and if you don't assign a value to it, there will be no value for use elsewhere.        In fact, to tell the truth, whether it is from the development time, or the current year, I have such an article, really embarrassing Ah! Forget it, I'll send out the embarrassing article.

Set method for IOS Properties _string = string; What do you mean?

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.