单例设计模式IOS
#import "ZBAccountInfo.h"
@interface ZBAccountInfo()
@end
static ZBAccountInfo *sharedObj = nil;
@implementation ZBAccountInfo
+(ZBAccountInfo *)sharedInstance{
@synchronized (self)
{
if (sharedObj == nil)
{
sharedObj= [[self alloc] init];
}
}
return sharedObj;
}
+(id)allocWithZone:(struct _NSZone *)zone{
@synchronized (self) {
if (sharedObj == nil) {
sharedObj = [super allocWithZone:zone];
return sharedObj;
}
}
return sharedObj;
}
@end