static OnlyOne *_instance = nil;
+ (instancetype)shareInstance
{
static dispatch_once_t onceToken ;
dispatch_once(&onceToken, ^{
_instance = [[super allocWithZone:NULL] init] ;
}) ;
return _instance;
}
+ (id)allocWithZone:(struct _NSZone *)zone
{
return [OnlyOne shareInstance];
}
- (id)copyWithZone:(struct _NSZone *)zone
{
return [OnlyOne shareInstance];
}
#if ! __has_feature(objc_arc)
- (oneway void)release
{
}
- (id)autorelease
{
return _instance;
}
- (NSUInteger)retainCount
{
return 1;
}
#endif