您的位置:首页 > 运维架构 > 网站架构

在外国网站上看到一个用artoolKit做的demo,学习了用gcd创建单列

2014-02-20 15:26 253 查看
外国网站:http://www.raywenderlich.com/42266/augmented-reality-ios-tutorial-location-based

看了下里面的demo,源代码里有个用gcd创建的实例;

于是就百度了下:dispatch_once_t 发现用它来创建单例很方便;

http://bj007.blog.51cto.com/1701577/649413/

+ (PlacesLoader *)sharedInstance {

static PlacesLoader *instance = nil;

staticdispatch_once_t onceToken;

dispatch_once(&onceToken, ^{

instance = [[PlacesLoader alloc] init];

});

return instance;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: