static Singleton* _instance = nil;
+ (instancetype) shareInstance
{
static dispatch_once_t onceToken ;
dispatch_once(&onceToken, ^{
_instance = [[self alloc] init] ;
}) ;
return _instance ;
}
static Singleton* _instance = nil;
+ (instancetype) shareInstance
{
static dispatch_once_t onceToken ;
dispatch_once(&onceToken, ^{
_instance = [[self alloc] init] ;
}) ;
return _instance ;
}
本文标题:面试题:简单实现一个单例类。
本文链接:https://www.haomeiwen.com/subject/lkiuettx.html
网友评论