如何释放这样分配的UIImageView?

| 我已经在tableview单元格的setBackground方法内分配了一个UIImageView,如下所示:
 [cell setBackgroundView:[[UIImageView alloc]initWithImage:rowBackground]];
当我在XCode 4中运行Analyze时,此行会突出显示,这可能是内存泄漏。我如何释放该UIImageView,因为我没有从释放调用获得引用的指针?     
已邀请:
您可以以不同的方式分配它(即,将其存储在ivar中并释放它),或者在其上调用
autorelease
,如下所示:
[cell setBackgroundView:[[[UIImageView alloc]initWithImage:rowBackground] autorelease]];
    
向其发送自动发布消息:
[cell setBackgroundView:[[[UIImageView alloc]initWithImage:rowBackground] autorelease]];
使用自动发布消息,您声明不想拥有超出发送消息范围的对象。     

要回复问题请先登录注册