单例宏定义的写法

 1 // 单例的声明
 2 // ## 拼接
 3 // 回车 换行
 4 #define singleton_interface(className) 
 5 + (instancetype)shared##className;
 6 
 7 // 单例实现
 8 #define singleton_implementation(className) 
 9 static className *manager = nil; 
10 + (instancetype)shared##className { 
11 static dispatch_once_t onceToken; 
12 dispatch_once(&onceToken, ^{ 
13 manager = [[[self class] alloc] init]; 
14 }); 
15 return manager; 
16 }
原文地址:https://www.cnblogs.com/leikun1113/p/5581628.html