dispatch_once(&onceToken, ^{\
_instance = [super allocWithZone:zone];\ });\
return _instance;\
}\
\
+(instancetype)share##className\ {\
static dispatch_once_t onceToken;\ dispatch_once(&onceToken, ^{\
_instance = [[className alloc]init];\ });\
return _instance;\
}\
-(id)copyWithZone:(NSZone *)zone\ {\
return _instance;\
}\
+(instancetype)alloc{\
if(_instance)\
{ return _instance;\
}\
return [super alloc];\
}\
-(instancetype)init{\
if(_instance)\
{ return _instance;}\
return [super init];\
}\
-(id)copy{\
if(_instance)\
{\
return _instance;\
}\
单例模式的几种实现方式return [super copy];\
}\
- (id)mutableCopy\
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论