title: Is this method of initializing singleton thread safe?
body: <p>this is a scope of code in our project, I think it is not thread-safe, because the scope</p>
  
  <pre><code>if(sharedHelper)
      return sharedHelper;
  </code></pre>
  
  <p>will cause problem, but I am not sure, could any one help me?</p>
  
  <pre><code>+(id) sharedHelper
  {
  static MyHelper *sharedHelper = nil;
  static dispatch_once_t onceToken;
  
  if(sharedHelper)
      return sharedHelper;
  
  dispatch_once(&amp;onceToken,^{
  
      sharedHelper = [[self alloc] init];
  });
  
  return sharedHelper;
  }
  </code></pre>