IOS第二天多线程-04简化单例模式
生活随笔
收集整理的這篇文章主要介紹了
IOS第二天多线程-04简化单例模式
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
******HMSingleton-ARC.h
// .h文件 #define HMSingletonH(name) + (instancetype)shared##name;// .m文件 #define HMSingletonM(name) \ static id _instance; \\ + (id)allocWithZone:(struct _NSZone *)zone \ { \static dispatch_once_t onceToken; \dispatch_once(&onceToken, ^{ \_instance = [super allocWithZone:zone]; \}); \return _instance; \ } \\ + (instancetype)shared##name \ { \static dispatch_once_t onceToken; \dispatch_once(&onceToken, ^{ \_instance = [[self alloc] init]; \}); \return _instance; \ } \\ - (id)copyWithZone:(NSZone *)zone \ { \return _instance; \ }****.m的文件中
@implementation HMMovieTool HMSingletonM(MovieTool) @end?
轉(zhuǎn)載于:https://www.cnblogs.com/ios-g/p/4795136.html
總結(jié)
以上是生活随笔為你收集整理的IOS第二天多线程-04简化单例模式的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【ubuntu】中文输入法安装二三事
- 下一篇: Session or Cookie?是否