开发者

Why Xcode say it may leak?

开发者 https://www.devze.com 2023-04-03 06:39 出处:网络
I defined splitBarArr in .h开发者_Go百科 file: @property (nonatomic, retain) NSMutableArray *splitBarArr;

I defined splitBarArr in .h开发者_Go百科 file:

@property (nonatomic, retain) NSMutableArray *splitBarArr;

And I also set it nil in viewDidUnload, and released it in dealloc.

Why XCode still say that it's a potential memory leak?

Img here: http://i.stack.imgur.com/3LMMZ.png


when assigning retain property the retain count increments by 1. Hence allocing array does +1 and assigning it to property via self does +1 again. The release in dealloc does -1 so you still have +1 left. Doing assigning like this will fix the problem:

self.splitBarArr = [NSMutableArray array];
0

精彩评论

暂无评论...
验证码 换一张
取 消