title: What is the proper way to declare static variables in Objective-C?
body: <p>Ok, still re-adjusting to things when switching between C, C++, C# and Objective-C so sometimes my head spins.  This time however, I'm more confused as to the proper way since I have seen at least three different ways to declare static variables in Objective-C, and there's a fourth if you consider it's just a superset of C itself.  So which of these is right?</p>
  
  <h3>Additional Question</h3>
  
  <p>If we want to share a stand-alone variable (i.e. not a static class variable, but one just defined in a header) is that done the same way as in 'C' (ala with 'extern' in the header?)</p>
  
  <hr>
  
  <h2>Option A</h2>
  
  <p><strong>Foo.h</strong></p>
  
  <pre><code>@interface Foo : NSObject{
      static int Laa;
  }
  
  @end
  </code></pre>
  
  <p><strong>Foo.m</strong></p>
  
  <pre><code>@implementation Foo
      ...
  @end
  </code></pre>
  
  <hr>
  
  <h2>Option B</h2>
  
  <p><strong>Foo.h</strong></p>
  
  <pre><code>@interface Foo : NSObject{
  }
  
  @end
  </code></pre>
  
  <p><strong>Foo.m</strong></p>
  
  <pre><code>static int Laa; // &lt;-- Outside of the implementation
  
  @implementation Foo
      ...
  @end
  </code></pre>
  
  <hr>
  
  <h2>Option C</h2>
  
  <p><strong>Foo.h</strong></p>
  
  <pre><code>@interface Foo : NSObject{
  }
  
  @end
  </code></pre>
  
  <p><strong>Foo.m</strong></p>
  
  <pre><code>int Laa; // &lt;-- Note no word 'static' here like in 'Option B'
  
  @implementation Foo
      ...
  @end
  </code></pre>
  
  <hr>
  
  <h2>Option D</h2>
  
  <p><strong>Foo.h</strong></p>
  
  <pre><code>static int Laa;
  
  @interface Foo : NSObject{
  }
  
  @end
  </code></pre>
  
  <p><strong>Foo.m</strong></p>
  
  <pre><code>@implementation Foo
      ...
  @end
  </code></pre>
  
  <hr>
  
  <h2>Option E</h2>
  
  <p><strong>Foo.h</strong></p>
  
  <pre><code>@interface Foo : NSObject{
  }
  
  @end
  </code></pre>
  
  <p><strong>Foo.m</strong></p>
  
  <pre><code>@implementation Foo
  
      static int Laa;
  
      ...
  
  @end
  </code></pre>
  
  <hr>
  
  <h2>Bonus question...</h2>
  
  <p>Do you have to use the word <code>extern</code> or is that only when you are using .c/.c++ files, not .m/.mm files?</p>