iOS单例模式

2017-06-23  本文已影响7人  Operation
staticFMDatabase*_dataDB;

+ (instancetype)shareInstance{

staticdispatch_once_tonceToken;

staticXDBData *dbData = nil;

dispatch_once(&onceToken, ^{

dbData = [[super allocWithZone:NULL] init];

});

return dbData;

}


+ (instancetype)allocWithZone:(struct_NSZone*)zone{
return[XDBData shareInstance];

}
- (instancetype)copyWithZone:(struct_NSZone*)zone{

return[XDBData shareInstance];

}
上一篇下一篇

猜你喜欢

热点阅读