+ (ThemeManager *)sharedInstance
{
static dispatch_once_t once; //只执行一次
static ThemeManager *instance = nil; //静态单例
dispatch_once( &once, ^{
instance = [[ThemeManager alloc] init];
} );
return instance;
}
GCD 单例
原创mb2928593829 ©著作权
©著作权归作者所有:来自51CTO博客作者mb2928593829的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
单例模式(懒汉式单例 and 饿汉式单例)
本文介绍两种单例模式,以及,多线程并发情况下的懒汉式单例模式改造及代码分析。
设计模式 单例模式 线程同步 多线程并发