Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.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
Objective c 函数内NSMutableArray的解除分配_Objective C_Memory_Memory Management_Nsmutablearray - Fatal编程技术网

Objective c 函数内NSMutableArray的解除分配

Objective c 函数内NSMutableArray的解除分配,objective-c,memory,memory-management,nsmutablearray,Objective C,Memory,Memory Management,Nsmutablearray,这是我的密码: - (void)showRectangles { NSMutableArray *rects = [[NSMutableArray alloc]init]; //....rest of code here [rects release]; } 这里的问题是,当我分析代码时,它会给我以下警告: 此时调用方不拥有的对象的引用计数的减少量不正确 我不明白为什么这会给我一个警告。有人能解释一下原因吗?通过展开问题导航器中的消息,xcode将为您指出每个引用计数操作。最终,这

这是我的密码:

- (void)showRectangles
{
  NSMutableArray *rects = [[NSMutableArray alloc]init];
  //....rest of code here
  [rects release];
}
这里的问题是,当我分析代码时,它会给我以下警告:

此时调用方不拥有的对象的引用计数的减少量不正确


我不明白为什么这会给我一个警告。有人能解释一下原因吗?

通过展开问题导航器中的消息,xcode将为您指出每个引用计数操作。最终,这将向您展示静态分析器是如何得出这个结论的

或者,您可能已经重新分配了变量
rects
(引入泄漏和过度释放)。

在“代码的其余部分”中的某些内容已经重新分配或已经释放
rects
;这两条线本身是完全正确的。