#define SINGLETON_H (name) + (instancetype) shared# #name; #if __has_feature (OBJ_ARC) #define SINGLETON_M (name) Static ID _ instance;+ (instancetype) shared# #name {static dispatch_once_t oncetoken;dispatch_once (&oncetoken, ^{_instance = [ [Self alloc] init];}); return _instance;} + (ID) allocwithzone: (struct _nszone *) zone{static dispatch_once_t oncetoken;dispatch_once (&oncetoken, ^{_ instance = [Super Allocwithzone:zone];}); return _instance;} + (ID) copywithzone: (struct _nszone *) Zone{return _instance;} #else # define SINGLETON_M (name) static ID _instance;+ (instancetype) shared# #name {static dispatch_once_t oncetoken; Dispatch_once (&oncetoken, ^{_instance = [[Self alloc] init]; }); return _instance;} + (ID) allocwithzone: (struct _nszone *) zone{static dispatch_once_t Oncetoken; Dispatch_once (&oncetoken, ^{_instance = [Super Allocwithzone:zone]; }); return _instance;} + (ID) copywithzone: (struct _nszone *) zone{return _instance;} -(OneWay void) release{}-(ID) autorelease{return _instance;} -(ID) retain{return _instance;} -(Nsuinteger) retaincount{return 1;} #endif