title: Why rename synthesized properties in iOS with leading underscores?
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>When creating a new project in Xcode 4, the boilerplate code adds an underscore character when it synthesizes the ivars in the implementation file as:</p>
  
  <pre><code>@synthesize window = _window;
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>@synthesize managedObjectContext = __managedObjectContext;
  </code></pre>
  
  <p>Can someone tell me what is being accomplished here? I'm not a complete nube, but this is one aspect of objective-C I don't understand. </p>
  
  <p>Another point of confusion; in the app delegate implementation, after synthesizing the window iVar as above, in the application didFinishLaunchingWithOptions: method the window and viewController ivars are referred to using self:</p>
  
  <pre><code>self.window.rootViewController = self.viewController
  [self.window makeKeyAndVisible];
  </code></pre>
  
  <p>but in the dealloc method it's _window, or _viewController</p>
  
  <p>Thanks</p>