Calling UIViews's subviews property increments subview retain count by 1?
I have this code:
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 retai开发者_StackOverflow中文版nCount]);//prints 2
i = superView.subviews.count ;
NSLog(@"retain odd %i", [subView retainCount]);//keeps printing 2
Is this an "expected" behavior ?. If so, what is the underlying logic ?
精彩评论