(有码)OC单例

来源:互联网 发布:彩虹岛 知乎 编辑:程序博客网 时间:2024/05/01 04:26


static Singleton* _instance =nil;


+ (Singleton *)shareSingleton{

    staticdispatch_once_t once;

    dispatch_once(&once, ^{

        _instance = [[superallocWithZone:nil]init];

    });

    return_instance;

}


+ (instancetype)alloc{

    return [selfshareSingleton];

}

0 0