zoukankan      html  css  js  c++  java
  • send to instance already dealloc nil error

    这个是因为发送消息的对象已经被dealloc了,然后再次发送[release]请求就不行了。所以可以retain或者alloc对象

    if (self.buttonsList) {
            
            for (int index = 0; index < 9; index ++) {
                
                UIButton *button = [[UIButton alloc]init];
                button.backgroundColor = [UIColor blueColor];
                button.tag = index;
                if (cellOffsetx >= (self.bgscrollview.frame.size.width - 5.0f)) {
                    
                    //new line
                    ++scrollviewLineNumber;
                    cellOffsetx = 5.0f;
                }
                
                button.frame = CGRectMake(cellOffsetx, cellHeight*scrollviewLineNumber + cellOffsety*scrollviewLineNumber + cellOffsety,cellWidth, cellHeight);
                cellOffsetx = cellOffsetx + cellWidth + 5.0f;
                
                //store the button
                [self.buttonsList addObject:button];
                //[self.bgscrollview addSubview:[self.buttonsList objectAtIndex:index]];
                [button release];

            }
          
        }

    - (void)dealloc
    {
     
        self.bgscrollview.delegate = nil;
        [_buttonsList release];  //不使用alloc的话会crash
        _buttonsList = nil;
        [_entriesArray release];
        _entriesArray = nil;
        [_alertView release];
        _alertView = nil;
        [_albumTitle release];
        _albumTitle = nil;
        [_bgscrollview release];
        _bgscrollview = nil;
        [_photosList release];
        _photosList = nil;
        [_customNav release];
        _customNav = nil;
        [_localView release];
        _localView = nil;
        [super dealloc];
    }

  • 相关阅读:
    编辑器 --- Visual Studio Code 英文界面转换成中文(简体)
    CSS3 -- column 实现瀑布流布局
    CSS3 -- 边框圆角
    CSS3 -- 弹性盒
    自适应布局要素
    Vue -- 基础知识
    Vue -- element-ui el-table 的合计在第一行显示并可点击
    如何在网页标题栏title加入logo(icon)图标?
    linux下暴力破解工具hydra【转】
    linux 服务简介
  • 原文地址:https://www.cnblogs.com/lisa090818/p/3504549.html
Copyright © 2011-2022 走看看