I. Accessing member variables using the _ member variable name
In a method, you can use the _ member variable name to access member variables in this object.
Note the point:
The 1> member variable must be a member variable in this object
2> This is not possible if the member variable is inherited from a parent class and this member variable in the parent class is set to @private.
3> can be used in conjunction with the & address character
Two. Accessing member variables using the Get Set method
Write a method that is dedicated to assigning values and values to access the member variables
Note the point:
The 1>set get method must be an object method, called by an object, to access the member variables inside the object. You must have an object, or get an object, to use Get,set
2>set is an assignment method, and get is the value method. The Get method has a return value that returns the specific value of this member after the call, so it cannot be used with the & accessor.
3> in principle as long as there are objects, or get the object can use the Get Set method, but if the class is only set,get implementation, no declaration, then Get,set is the private method of this class, can only be used in this class, not used outside the class, and even subclasses are not available.
Three. Using the. Grammar
The. syntax is called the Set,get method at precompilation, so the essence is the Set,get method
Note the point:
1> to use point syntax to ensure that there are objects, or to get the object
2> to use. Syntax you must ensure that there are set,get methods for member variables
3> point syntax cannot be used with the & address, for the same reason as Set,get
Four. Using pointers
Assign a member variable in a way that uses the pointer "object name->_ member name"
Note the point:
1> when a member is @public, you can access the member directly from the outside using the pointer method
2> when a member is @protected, it cannot be used outside the class, can be used in a class, subclass, or in other classes, but only if the object must be obtained.
3> You cannot use this method in a subclass when the member is @private, you can only access it by using the Get,set method.
Self,super, can be used flexibly in programming, with pointer method, Set,get method.
Access to OC member variables and point syntax