Which one synchronization method to use to ensure a singleton remains a singleton?
+(Foo*)sharedInstance { @synchronized(self) { if (nil == _shar
The fastest thread safe way to do this is with Grand Central Dispatch ( libdispatch ) and dispatch_once()
+(MyClass *)sharedInstance { static MyClass *sharedInstance = nil; static dispatch_once_t pred; dispatch_once(&pred, ^{ sharedInstance = [[MyClass alloc] init]; }); return sharedInstance; }