Where is the leak here?
-(IBAct开发者_StackOverflowion)startGameButtonClicked:(id)sender{
//gameViewController = NULL;
//[gameViewController release];
//[gameViewController dealloc];
if(!gameViewController){
gameViewController = [[GameViewController alloc] initWithNibName:@"GameViewController" bundle:nil];
}
appDelegate.ScoreID=0;
[gameViewController resetLevel];
[gameViewController resetTheGame];
[self.navigationController pushViewController:gameViewController animated:YES];
} <---Says the leak is here
set up gameViewController as a property in the .h
@property(nonatomic,retain) GameViewController *gameViewController;
and in the .m
@synthesize gameViewController
then use the property when assigning
self.gameViewController = [[GameViewController alloc] initWithNibName:@"GameViewController" bundle:nil];
and release at the end
[self.navigationController pushViewController:gameViewController animated:YES];
[gameViewController release];
Each time the button is clicked, you make a new gameViewController and push it into self.navigationController.
You want to not make a new one each time.
精彩评论