单例创建方法

 方法一

+ (instancetype)shareManage
{
    static Manage *manage = nil;
    
    if (manage == nil)
    {
        manage = [[Manage alloc]init];
        
    }
    
    
    return manage;
    
}
方法二
+ (instancetype)shareService
{
    static ViewController *shareM = nil;
    
    static dispatch_once_t predicate;
    
    dispatch_once(&predicate, ^{
       
        shareM = [[ViewController alloc]init];
        
    });
    
    return shareM;
}
 
原文地址:https://www.cnblogs.com/huoxingdeguoguo/p/4667531.html