title: why doesn't setting a static variable to nil defeat purpose of static variable?
body: <p>The code below is from the Big Nerd Ranch iOS programming book, 3rd edition. It's a class method that checks whether the singleton class BNRItemStore has been instantiated. If it has, it returns the singleton instance, and if it hasn't it creates it.  The part I don't understand is the static variable. I know that static variables keep state, however, wouldn't calling the method a second time reset the *sharedStore back to nil? i.e. isn't this an assignment which would erase the creation of the singleton instance once the method was called again?</p>
  
  <pre><code>static BNRItemStore *sharedStore = nil;
  </code></pre>
  
  <p>Method</p>
  
  <pre><code>+(BNRItemStore *)sharedStore
  {
     static BNRItemStore *sharedStore = nil;
     if (!sharedStore)
         sharedStore = [[ super allocWithZone:nil ] init ];
     return sharedStore;
  }
  </code></pre>