dispatch_once 单例设计模式

//单例模式
#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
相关文章
相关标签/搜索