[关闭]
@iwanglong 2019-02-21T07:01:43.000000Z 字数 598 阅读 237

设计模式

iOS


六大设计原则
责任链
桥接
适配器
单例
  1. @implementation Single
  2. + (id)sharedInstance{
  3. static Single *instance = nil;
  4. static dispatch_once_t onceToken;
  5. dispatch_once(&onceToken, ^{
  6. instance = [[super allocWithZone:NULL] init];
  7. });
  8. return instance;
  9. }
  10. + (instancetype)allocWithZone:(struct _NSZone *)zone{
  11. return [self sharedInstance];
  12. }
  13. - (id)copyWithZone:(nullable NSZone*)zone{
  14. return self;
  15. }
  16. @end
命令
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注