http://stackoverflow.com/questions/2199106/thread-safe-instantiation-of-a-singleton
+(MyClass *)sharedInstance
{
static MyClass *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [MyClass alloc];
sharedInstance = [sharedInstance init];
});
return sharedInstance;
}
沒有留言:
張貼留言