单例模式补充 -14

#mport "XMGPerson.h"

@interface XMGPerson()

@end

@implementation XMGP


static id _instance;

+(instancetype)allocWithZone:(struct NSZone *)zone{

static dispatch_once_t onceToken;

dispatch_once(&onceToken,^{

_instence = [super allocWithZone:zone];

});

return _instance;

}

static  leftScrollView = nil;

i

+(instancetype)sharedInstance{

static dispatch_once_t onceToken;

dispatch_once(&onceToken,^{

return _instance;

});

}

-(id)copyWithZone:(NSZone *)zone{

return _instance;

}

你可能感兴趣的:(单例模式补充 -14)