OC版单例
+ (instancetype) sharedInstance {
static id sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ sharedInstance = [[self alloc] init]; });
return sharedInstance;
}
- Swift版
static let sharedInstance : <#SingletonClass#> = <#SingletonClass#>()
网友评论