title: iOS: Usage of self and underscore(_) with variable
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/822487/how-does-an-underscore-in-front-of-a-variable-in-a-cocoa-objective-c-class-work">How does an underscore in front of a variable in a cocoa objective-c class work?</a>  </p>
  </blockquote>
  
  
  
  <p>I have been very confused with using self or underscore with variable name after synthesizing it like below:</p>
  
  <pre><code>In .h file:
  @property(nonatomic, strong) NSMutableArray *users;
  
  In .m file:
  @synthesize users = _users;
  </code></pre>
  
  <p>Based on my understandings when I use <code>self.users</code>, OS will make sure to release previously allocated memory in set method so we don't need to take care explicitly.</p>
  
  <p><code>_users</code> is an instance variable for users and should be normally used while accessing the users variable. If I use <code>_users</code> to change its value then it won't fire KVO delegate which will not notify a class observing users value change.</p>
  
  <p>Moreover, <code>self.users</code> allows differentiating dummy variable in the method name like below,</p>
  
  <pre><code>- (void)assignUsers:(NSMutableArray*)users {
        self.users = users;
  }
  </code></pre>
  
  <p>Could someone please tell me if there is anything that I understood wrong or missing while using <code>_users</code> or <code>self.users</code>?</p>