开发者

Can't find a leak from the Static Analyzer

I am getting some errors from the Clang Static Analyzer saying that I have a few leaks from the following code. However I am u开发者_如何学JAVAnable to find the leak. Please tell me where the leak is.

 Favourites *fav = [[Favourites alloc] initWithNibName:@"Favourites" bundle:nil];
if (viewController == fav) {
    [fav doHud];
    [fav release];
}


fav won't be released if viewController does not end up == to fav. You are not setting viewController to be equal to fav so it won't release. Move[fav release] outside the if and you should be fine.

or get rid of the[fav release] altogether and just use autorelease like:

Favourites *fav = [[[Favourites alloc] initWithNibName:@"Favourites" bundle:nil] autorelease];

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜