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