我有这段代码:
UIView *superView = [[UIView alloc] init];
UIView *subView = [[UIView alloc] init];
[superView addSubview:subView];
[subView release];
NSLog(@"retain before %i", [subView retainCount]);//prints 1
int i = superView.subviews.count ;
NSLog(@"retain after %i", [subView retainCount]);//prints 2
i = superView.subviews.count ;
NSLog(@"retain odd %i", [subView retainCount]);//keeps printing 2
这是“预期的”行为吗?如果是这样,基本逻辑是什么?