I am getting some errors from the Clang Static Analyzer saying that I have a few leaks from the following code. However I am unable 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];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.