首页 > 其他 > 详细

dispatch_once 单例设计模式

时间:2015-04-01 13:39:54      阅读:291      评论:0      收藏:0      [点我收藏+]
//单例模式
#import "MySingleton.h"
@implementation MySingleton
- (instancetype) sharedInstance{
    static MySingleton *SharedInstance = nil; 
    static dispatch_once_t onceToken; 
    dispatch_once(&onceToken, ^{
            SharedInstance = [MySingleton new];
        });
    return SharedInstance; 
}
@end



dispatch_once 单例设计模式

原文:http://my.oschina.net/u/1782374/blog/394561

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!