调用UIViews的子视图属性增量子视图保留计数为1?

时间:2011-07-01 17:15:44

标签: uiview retaincount subviews

我有这段代码:

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

这是“预期的”行为吗?如果是这样,基本逻辑是什么?

0 个答案:

没有答案