我知道以前也有人回答过类似的问题
here
,但我只是想让自己更明白一点。这是我的设想。。。
我有一个helper类方法,它返回一个已分配的UIImageView,如下所示。
+(UIImageView *)tableCellButton{
return [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image"]] autorelease];
}
然后,在我的一个UIViewController方法中,我就是这样使用它的。。
UIImageView *imageView = [Helper tableCellButton];
imageView.frame = cell.backgroundView.bounds;
imageView.tag = 250;
[cell.backgroundView addSubview:imageView];
我的问题是如何释放这种记忆。我没有使用自动释放池(应用程序创建的池除外),而且变量不是iVar/属性(因此在调用dealloc时不会释放)。在这种情况下,我有责任在调用内存后释放它吗?自动释放什么时候起作用?谢谢你的帮助!