title: How to properly implement ARC compatible and `alloc init` safe Singleton class?
body: <p>I saw thread safe version</p>
  
  <pre><code>+(MyClass *)singleton {
      static dispatch_once_t pred;
      static MyClass *shared = nil;
  
      dispatch_once(&amp;pred, ^{
          shared = [[MyClass alloc] init];
      });
       return shared;
  }
  </code></pre>
  
  <p>but what would happen if someone just calls <code>[MyClass alloc] init]</code> ? How to make it return same instance as the <code>+(MyClass *)singleton</code> method?</p>