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