@implementation MyClass+ (instancetype)allocWithZone:(struct _NSZone *)zone { static dispatch_once_t onceToken; static MyClass *share; dispatch_once(&onceToken, ^{ share = [[super allocWithZone:NULL] init]; }); return share;}+ (instancetype)shareInstance{ return [[self alloc] init];}@end复制代码