情况:有推送 UIViewController 的 UINavigationController。
1.UIViewController强引用UINavigationController
@property(nonatomic,readonly,retain) UINavigationController *navigationController
2.UINavigationController 将视图控制器存储在 NSArray 中
@property(nonatomic,copy) NSArray *viewControllers;
UINavigationController 应该对此 NSArray 有强引用(否则将被释放)。
3.NSArray 对包含的视图控制器有很强的引用。
更新:让我们想象一下我们在代码中的某个地方:
UIViewController *A = [ [UIViewController alloc] init ];
UINavigationController *B = [ [ UINavigationController alloc ] initWithRootViewController:A ];
// Here we have strong reference in A to B, in B to B.viewControllers (count == 1) and in B.viewControllers to A.
// Local variable's strong references to A and B
A = nil; B = nil;
// Local variable's strong references has gone
// But we should still have retain loop here
// Magic !?? :)
我的问题是为什么我们这里没有保留循环?