title: What is the proper way to declare a global variable in Objective-C
body: <p>So, I was wondering what the proper way to declare a global variable is in an iOS Project.
  I don't want it set as a property, because the variable should not be accessible from outside the class.</p>
  
  <p>I am going to provide a few ways I have seen, let me know which is the proper way, and if there is another way that is better.</p>
  
  <p>This way I add the global variable inside curly braces after the <code>@interface</code> declaration in the implementation file <code>.m</code>. Then I can initialize the variable in the <code>viewDidLoad</code></p>
  
  <pre><code>#import "ViewController.h"
  
  @interface ViewController () {
      int globalVariableTest;
  }
  @end
  
  @implementation ViewController
  </code></pre>
  
  <p>Another way I add the global variable inside curly braces after the <code>@implementation</code> declaration in the implementation file <code>.m</code>. Again intializing in the <code>viewDidLoad</code></p>
  
  <pre><code>#import "ViewController.h"
  
  @interface ViewController ()
  
  @end
  
  @implementation ViewController {
         int globalVariableTest;
  }
  </code></pre>
  
  <p>Another way is adding the variable after the <code>@implementation</code> without the curly braces, also this allows me to set the intial value without the <code>viewDidLoad</code></p>
  
  <pre><code>#import "ViewController.h"
  
  @interface ViewController ()
  
  @end
  
  @implementation ViewController
  
  int globalVariableTest = 1;
  </code></pre>
  
  <p>Another way is to add the variable after the <code>@interface</code> inside the header file <code>.h</code></p>
  
  <pre><code>@interface ViewController : UIViewController
  {
      int globalVariableTest;
  }
  </code></pre>
  
  <p>So if there is a better way please let me know, all help will be appreciated!</p>