Grand Central Dispatch Singletons

So… what’s the recommended way (thread safety + performance) to implement a singleton?

Well.. it looks pretty much like this!
[cc lang=”objc”]
+ (instancetype)sharedInstance
{
static dispatch_once_t pred;
static Foo* bar = nil;

dispatch_once(&pred, ^{ bar = [[Foo alloc] init]; });
return bar;
}[/cc]

%d