IOS 使用dispatch_once 创建单例

+ (instantClass *)sharedClient {

static instantClass *_sharedClient = nil;

static dispatch_once_t onceToken;

dispatch_once(&onceToken, ^{

_sharedClient = [[instantClass alloc] init];

});

return _sharedClient;

}

 

posted @ 2014-04-29 10:31  菜鸟程序猿  阅读(208)  评论(0编辑  收藏  举报