title: What is best way to share class instance (create and share singleton)?
body: <p>I know 2 ways. What is better? And anything better than 2 ways?</p>
  
  <pre><code>+ (MyClass *)shared {
      /*
      static MyClass *sharedInstance = nil;
  
      @synchronized(self) {
          if (sharedInstance == nil) {
              sharedInstance = [[self alloc] init];
          }
      }
      return sharedInstance;
      */
  
      /*
      static dispatch_once_t pred;
      static MyClass *sharedInstance = nil;
  
      dispatch_once(&amp;pred, ^{
          sharedInstance = [[self alloc] init];
      });
  
      return sharedInstance;
      */ 
  } 
  </code></pre>