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];
    }

  • 相关阅读:
    HDU 6134 Battlestation Operational(莫比乌斯反演)
    HDU 5514 Frogs(容斥原理)
    HDU 5909 Tree Cutting(FWT+树形DP)
    BZOJ 1030 [JSOI2007]文本生成器(AC自动机)
    BZOJ 2938 [Poi2000]病毒(AC自动机)
    HDU 6118 度度熊的交易计划(费用流)
    HDU 6119 小小粉丝度度熊(Two pointers)
    Codeforces 839E Mother of Dragons(极大团)
    Codeforces 839D Winter is here(容斥原理)
    BZOJ 2434 [Noi2011]阿狸的打字机(AC自动机)
  • 原文地址:https://www.cnblogs.com/lisa090818/p/3504549.html
Copyright © 2011-2022 走看看