?????????????????????????
????????????????XXXClass *obj = [XXXClass [alloc] init];??????????????
??????????????shareInstance??????????????????????
?????????????
/**
*  ????static????????????????????????
*/
static id _instance;
/**
*  ??????????????????alloc?????????????????????????
*/
+(instancetype)allocWithZone:(struct _NSZone *)zone
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken?? ^
{
_instance = [super allocWithZone:zone];
});
return _instance;
}
/**
*  ????????????Σ????[[xxx alloc] init]???????
*/
-(instancetype)init
{
__block typeof(self) onceSelf = self;
static dispatch_once_t onceToken;
dispatch_once(&onceToken?? ^
{
onceSelf = [super init];
if(onceSelf)
{
// ?????????????
}
});
return onceSelf;
}
/**
*  ???????????????????????????
*/
+(instancetype)sharedInstance
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken?? ^
{
_instance = [[self alloc] init];
});
return _instance;
}
/**
*  ????????????????????????????????<NSCopying>Э??
*/
-(id)copyWithZone:(NSZone *)zone
{
return _instance;
}