title: Static variable scope within class?
body: <p>Can anyone tell me what the scope of the static variable in the class below is?</p>
  
  <pre><code>@implementation SharedManager
  
  static id myInstance = nil;
  
  +(id)sharedInstance {
      if(myInstance == nil) {
          myInstance = [[self alloc] init];
      }
      return myInstance;
  }
  </code></pre>
  
  <p>In a test I created an instance from the class and then released it, but noticed that on creating a second instance that the static was not nil (i.e. pointing to the previously released object) For the test I fixed this by overriding -(void)dealloc for the class.</p>
  
  <pre><code>-(void)dealloc {
      NSLog(@”_deal: %@”, [self class]);
      [super release]
      myInstance = nil
  }
  </code></pre>
  
  <p>gary</p>