I have a base Store
class with many methods that all stores inherit. Each store is a singleton. Right now, each store defines its own near-identical method:
+ (Store *)instance {
static SubStore *store = nil;
if (!store) {
store = (SubStore *) [[super allocWithZone:nil] init];
[store setupDefaults];
}
return store;
}
Is there any way to craft a singleton method in a way that the method can simply be added to the base class and inherited by the subclasses?