title: Difference Between Declaring a Variable Under @Implementation And @Interface Under .m file
body: <p>I have been learning Objective-C for awhile. From what I learned, I know that when you declare a variable inside <code>@interface</code> in the <strong>.h file</strong>, the variable can be accessed publicly(similar as a public variable in java).</p>
  
  <pre><code>@interface MyObject
  
  @property NSInteger intData;
  
  @end
  </code></pre>
  
  <p>But when you declare it inside <code>@interface</code> in the <strong>.m file</strong>. It can only be accessed inside the .m file under @implementation only, unless you provide a getter and setter for it. </p>
  
  <pre><code>@interface MyObject ()
  
  @property NSInteger intData;
  
  @end
  </code></pre>
  
  <p>But I also noticed another way of declaring a variable, which is declaring it under <code>@implementation</code>  </p>
  
  <pre><code>@implementation
  
  NSInteger intData;
  
  @end
  </code></pre>
  
  <p>and I see that it works the same way as declaring it under <code>@interface</code> with <code>@property</code> in .m file</p>
  
  <p>I don't understand the difference between the two(declaring under @implementation and under @interface(in <strong>.m file</strong>). </p>
  
  <p><em>I've already searched through stack about this, but they were all talking about the difference between @implementation and @interface(in <strong>.h file</strong>). So think this is not a duplicate.</em> </p>