作者:mobiledu2502873611 | 来源:互联网 | 2023-08-19 17:07
创建一个BNRitemStore类的单实例
1 2 3 4 5 6 7 8 9 10 11
| +(BNRitemStore *)sharedStore{
static BNRitemStore *sharedStore = nil;
if(!sharedStore){
sharedStore = [[super allocWithZone:nil]init];
}
return sharedStore;
}
+(id)allocWithZone:(NSZone *)zone{
return [self sharedStore];
} |
第一个方法中使用了allocWithZone方法,第二个方法中又使用了sharedStore方法,这二者不会造成循环吗?该如何理解呢?