单例写法

+ (id)sharedInstance {

static CommonHttpUlity *sharedInstance = nil;

static dispatch_once_t once;

dispatch_once(&once, ^{

sharedInstance = [[self alloc] init];

});

return sharedInstance;

}

推荐阅读更多精彩内容