title: Property declaration in Objective-C
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>So i have found out that you have to use underscore when synthesizing properties and that doesn't make a single bit of sense to me.</p>
  
  <p>So, let's start.
  In our .h file we write this line:</p>
  
  <pre><code>@property (nonatomic) double speed;
  </code></pre>
  
  <p>In our .m file we do this:</p>
  
  <pre><code>@synthesize speed = _speed;
  </code></pre>
  
  <p>Why? As far as I know, property makes an instance variable and creates setters and getters for it.
  But what the hell does line </p>
  
  <pre><code>@synthesize speed = _speed 
  </code></pre>
  
  <p>do?
  As common sense tells me, we assign value in _speed to speed. Okay.
  Where did we declare _speed? Why doesn't compiler give us an error? What is it supposed to mean? Why such an obfuscated code?</p>
  
  <p>My questions here:</p>
  
  <p>What happens if I do just </p>
  
  <pre><code>@synthesize speed;
  </code></pre>
  
  <p>without _speed, will I get error or some bugs?
  What is the reason after this syntax? What were they thinking when making it? Where does _speed come from? What is it? Is it a pointer or a real value? What is going on?</p>