oc 单例

单例模式:

//static id _instace;
//
//+ (id)allocWithZone:(struct _NSZone *)zone
//{
//    static dispatch_once_t onceToken;
//    dispatch_once(&onceToken, ^{
//        _instace = [super allocWithZone:zone];
//    });
//    return _instace;
//}
//
//
//- (id)copyWithZone:(NSZone *)zone
//{
//    return _instace;
//}
//
//+ (instancetype)sharedInstance
//{
//    static dispatch_once_t onceToken;
//    dispatch_once(&onceToken, ^{
//        _instace = [[self alloc] init];
//    });
//    return _instace;
//}
原文地址:https://www.cnblogs.com/HJiang/p/5082541.html