This article reproduces the difference between self and underline from iOS .
1. The method was called through SELF.XXX Access: Contains the set and get methods. Access by underlining is to get its own instance variable, without the method of set and get.
2.self.xxx is access to a property, while _xxx is access to a local variable. All the members that are declared as attributes, and then ios5 need to use the compile instruction @synthesize to tell the compiler to help generate the properties of the getter and setter methods, after which the directive can be specified without regard, and by default the compiler will help us build.
The translator has a priority when generating the Getter,setter method, and he first looks for the Getter,setter method of whether the user defines the attribute in the current class, and if so, the compiler skips and no longer builds, using a user-defined method. This means that you are invoking a getter method when using Self.xxx. Will add one to the reference count, while the _XX
Does not use the reference count plus one. So using self.xxx is a better choice because it is compatible with lazy loading, and avoids the use of the slip line when the self is ignored, which easily causes circular references in the block. At the same time, using _ is not a property of the parent class, because it is only access to local variables.
Summary: The self method is actually called indirectly using the Get and set methods, and the underscore method is to manipulate the variables directly.
Ios-self. and underline access differences