iOS-单利

.h类

+(SQLManager *)shareManager;//单利

.m类

+(SQLManager *)shareManager
{
    static SQLManager *manager = nil;
    //保证只调用一次
    static dispatch_once_t once;
    dispatch_once(&once, ^{
        manager = [[self alloc] init];
    });
    
    return manager;
}

你可能感兴趣的:(iOS-单利)