title: Correct way to create/use a Singleton NSMutableArray for Xcode 4
body: <p>I've reviewed (and tried) a bunch of the threads here regarding Singletons and NSMutableArrays. I'm new to Objective-C so please bear with me.</p>
  
  <p>I simply want to create a few arrays that can be accessed from any view/.m file.</p>
  
  <p>What is the best (or most concise) coding for a Singleton?</p>
  
  <p>Below is what I have now and I get
  1 warning at .m '@implementation' - "Incomplete implementation"
  1 error at usage in a view .m file - "initializer element is not a compile-time constant"</p>
  
  <p>This is the code I have now - my GlobalData.h file:</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  @interface GlobalData : NSObject {    
      NSMutableArray *listOfHeadings;
      NSMutableArray *listOfItems1;
      NSMutableArray *listOfItems2;
  }    
  @property(nonatomic,retain)NSMutableArray *listOfHeadings;
  @property(nonatomic,retain)NSMutableArray *listOfItems1; 
  @property(nonatomic,retain)NSMutableArray *listOfItems2; 
  +(GlobalData*)getInstance;  
  @end
  </code></pre>
  
  <p>My GlobalData.m file:</p>
  
  <pre><code>#import "GlobalData.h"
  
  @implementation GlobalData
  @synthesize listOfHeadings;
  @synthesize listOfItems1;
  @synthesize listOfItems2;
  static GlobalData *instance=nil; 
  
  +(GlobalData *)getInstance    
  {    
      @synchronized(self)    
      {    
          if(instance==nil)    
          {    
              instance= [GlobalData new];    
          }    
      }    
      return instance;    
  }    
  @end
  </code></pre>
  
  <p>And in a view .m file (simplified):</p>
  
  <pre><code>#import GlobalData.h
  
  GlobalData *globDat=[GlobalData getInstance]; //error occurs here
  </code></pre>
  
  <p>Can someone point out the trouble and if there's better coding, please enlighten me - thanks!</p>
  
  <p>EDIT</p>
  
  <p>Here's a few links I've tried to use:</p>
  
  <p><a href="https://stackoverflow.com/questions/7636057/can-i-have-a-single-nsmutablearray-in-my-multiple-views-application">Can i have a single NSMutableArray in my multiple views application?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/5046142/iphone-help-with-singleton-class">iPhone help with singleton class</a></p>