这几天看GCD,居然可以实现单例:
- (id) sharedInstance
{
static MySingleton *SharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
SharedInstance = [MySingleton new];
});
return SharedInstance;
}
这几天看GCD,居然可以实现单例:
- (id) sharedInstance
{
static MySingleton *SharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
SharedInstance = [MySingleton new];
});
return SharedInstance;
}
转载于:https://www.cnblogs.com/celestial/archive/2012/07/10/2584980.html