ios--->self.view.window在逻辑判断中的作用

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    if (self.view.window == nil) {
        self.view = nil;
    }
}

iOS程序里面,window是程序视图层次体系的最高层。所有能看到的view,都是要加到这个window上才能被看到。

不管是直接被加到window上,还是通过superview被间接的加到window上,总之一个view你要想看到它,它必须要被加到一个window上去。

所以如果一个view的window属性为nil的话,就说明这个view没有被加到任何window上,是无法看到的。

原文地址:https://www.cnblogs.com/frankltf/p/7844084.html