当我继续学习时,这本书实现了一个单例。我理解使用它的原因,但我只是想澄清一下代码。
+ (BNRItemStore *)defaultStore
{
static BNRItemStore *defaultStore = nil;
if(!defaultStore)
defaultStore = [[super allocWithZone:nil] init];
return defaultStore;
}
在行中static BNRItemStore * defaultStore = nil;
直到返回语句。我的问题是;我一直在调用这个类,[[BNRItemStore defaultStore] someMethod];
在另一个类或应用程序的一部分中,defaultStore 变量将设置为 nil?
干杯