//单例的创建
/*
//第一种
static ExplicationTableViewManager * _shareInstance;
+(ExplicationTableViewManager *)sharedInstance{
@synchronized(self){//这个东西其实就是 一个加锁。如果self 其他线程访问,则会阻塞。这样做一般是用来对单例 进行一个死锁的保护
if (_shareInstance == nil) {
_shareInstance = [[self alloc] init];
}
}
return _shareInstance;
}
*/
//第二种方式
+ (ExplicationTableViewManager *)sharedInstance
{
static dispatch_once_t once;
static ExplicationTableViewManager *_shareInstance;
dispatch_once(&once, ^{
_shareInstance = [[self alloc] init];
});
return _shareInstance;
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。