‘# 简单的单例
oc:
+(instancetype)sharedInstance
{
static id sharedInstance = nil;
static dispath_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[self alloc]init];
});
return sharedInstance;
}
swift:
static let sharedInstance : <#SingletonClass#> = <#SingletonClass#> ()
网友评论