.h文件
///创建单例类+ (instancetype)sharedInstance;+ (instancetype) alloc __attribute__((unavailable("call sharedInstance instead")));+ (instancetype) new __attribute__((unavailable("call sharedInstance instead")));- (instancetype) copy __attribute__((unavailable("call sharedInstance instead")));- (instancetype) mutableCopy __attribute__((unavailable("call sharedInstance instead")));复制代码
.m文件
///单例类+ (instancetype)sharedInstance{ static POrderGoodsInfoManager *manager = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ manager = [[super allocWithZone:NULL] init]; }); return manager;}复制代码