zoukankan      html  css  js  c++  java
  • 【ios】收到系统内存警告时,应如何释放内存

    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
    
        if (_userInfoViewCtl != nil && [_userInfoViewCtl isViewLoaded]) {
            if (_userInfoViewCtl.view.window == nil) {
                self.userInfoViewCtl = nil;
            }
        }
    }

      

    -(KEUserInfoViewController *) userInfoViewCtl
    {
        if (!_userInfoViewCtl) {
            _userInfoViewCtl = [[KEUserInfoViewController alloc] init];
        }
        return _userInfoViewCtl;
    }
    

      

    注意_userInfoViewCtl和self.userInfoViewCtl的用法

    这样做的原因是属性的延迟加载,若 _userInfoViewCtl.view.window 这里使用self.userInfoViewCtl.view.window的话,那么这个值一直都不会是nil,因为每次都用都会创建

  • 相关阅读:
    HTTP协议
    django-两种方式对单表的操作
    模态框对话
    django
    web框架原理
    DNS详解
    jQuery
    初识web框架
    练习:简单主页搭建
    多表查询
  • 原文地址:https://www.cnblogs.com/kaysun/p/5474900.html
Copyright © 2011-2022 走看看