Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
分析后XCode NSIntegerv返回内存泄漏_Xcode_Uitableview_Nsinteger - Fatal编程技术网

分析后XCode NSIntegerv返回内存泄漏

分析后XCode NSIntegerv返回内存泄漏,xcode,uitableview,nsinteger,Xcode,Uitableview,Nsinteger,我用UITableView创建了这个代码,使单元格的颜色交替显示为白色和灰色 如何在没有内存泄漏的情况下更正此问题?谢谢 您的代码是: cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_white.png"]]; 这会泄漏UIImageView。您分配了它,但之后没有释放它 要修复: UIImageView* imageView = [[UIImageView alloc] ini

我用
UITableView
创建了这个代码,使单元格的颜色交替显示为白色和灰色

如何在没有内存泄漏的情况下更正此问题?谢谢

您的代码是:

cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_white.png"]];
这会泄漏
UIImageView
。您分配了它,但之后没有释放它

要修复:

UIImageView* imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_white.png"]]; 
cell.backgroundView = imageView;
[imageView release];
analyzer警告中的箭头有点误导——它们试图显示执行流程,通过代码,进入导致泄漏的方法,然后退出。文本消息是重要的组成部分


(另外,我怀疑您想要
tbl\u RowIndex1%2
,而不是
tbl\u RowIndex1%=2

您是否使用ARC?