2012-07-23 95 views
0

這裏內部重分配的NSMutableArray的是我的代碼:一個功能

- (void)showRectangles 
{ 
    NSMutableArray *rects = [[NSMutableArray alloc]init]; 
    //....rest of code here 
    [rects release]; 
} 

這裏的問題是,當我對代碼進行分析,它給了我這樣的警告:

Incorrect decrement of the reference count of an object that is not owned at this point by the caller

我不不明白爲什麼這給我一個警告。誰能解釋爲什麼?

+0

「剩餘代碼」中的某些內容已重新分配或已釋放「rects」;這兩條線本身是完全正確的。 – 2012-07-23 06:04:17

回答

1

通過擴展問題導航器中的消息,xcode會指出每個ref計數op。最終,這會告訴你靜態分析儀是如何得出這個結論的。

或者,您可能已經沿途重新分配了變量rects(引入泄漏和過度釋放)。

+0

發現真正的問題。感謝您指出了這一點! – 2012-07-23 06:33:50