singleton

+ (id)allocWithZone:(NSZone *)zone

{

 

    static dispatch_once_t onceToken;

    dispatch_once(&onceToken, ^{

        _instance= [super allocWithZone:zone];

    });

    return _instance;

 

 

}

原文地址:https://www.cnblogs.com/dengchaojie/p/4743402.html