GCD 创建单例

#import "UserEntity.h"


@implementation UserEntity

@synthesize login;


static UserEntity * _sharedInstance = nil;


+ (id)sharedInstance

{

    static dispatch_once_t p = 0;

    dispatch_once(&p, ^{

        _sharedInstance = [[UserEntity alloc] init];

    });

    return _sharedInstance;

}


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