IOS Getter Setter

Source: Internet
Author: User

Getter Setter names a member variable

Setter methods set member variable values

1. Setter methods must be object methods cannot be class methods

2. There must be no return value

3. Start with set, and set to follow the name of the member you want to set the white energy of the names to remove the underscore, and capitalize the first letter

4. Must have the parameter parameter type must and the member variable type always the parameter name is the member variable name removes the underscore

The Getter method is used to return the value of a member variable

1. Getter must be an object method

2. There must be a return value return value must be the same as the obtained member variable type

3. The method name is the name of the obtained member variable, minus the underscore.

4. There must be no parameters

Note the benefit of the member variable starting with _ is that it can be used to differentiate between local variables and member variables

If a property only provides a getter method that does not provide a setter method, I call this property a read-only property

If a property only provides a setter method and does not provide a getter method we call this property a write-only property

If a property provides both getter and setter methods, we call this property a readable writable property

If a property has no getter method and no setter method becomes a private property

IOS Getter Setter

Related Article

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.