iOS单例的写法

在.h中

+ (shareInstance*)sharedManager;

.m中

+ (shareInstance*)sharedManager

{

staticshareInstance*sharedAccountManagerInstance =nil;

staticdispatch_once_tpredicate;

dispatch_once(&predicate, ^{

sharedAccountManagerInstance = [[selfalloc]init];

});

returnsharedAccountManagerInstance;

}

你可能感兴趣的:(iOS单例的写法)