利用GCD创建单例

代码如下:
+ (instancetype)shareInstance {
    static aClass * shareInstance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        shareInstance = [[aClass alloc] init];
        [shareInstance saveImage];
    });

    return shareInstance;
}

你可能感兴趣的:(利用GCD创建单例)