BNRItemStore是一个单身人士,我对为什么super allocWithZone:必须调用而不是普通的 old感到困惑super alloc。然后覆盖alloc而不是allocWithZone.
#import "BNRItemStore.h"
@implementation BNRItemStore
+(BNRItemStore *)sharedStore {
static BNRItemStore *sharedStore = nil;
if (!sharedStore)
sharedStore = [[super allocWithZone: nil] init];
return sharedStore;
}
+(id)allocWithZone:(NSZone *)zone {
return [self sharedStore];
}
@end