-(IBAction)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
答案 0 :(得分:2)
将gameViewController设置为.h
中的属性@property(nonatomic,retain) GameViewController *gameViewController;
和.m
@synthesize gameViewController
然后在分配时使用该属性
self.gameViewController = [[GameViewController alloc] initWithNibName:@"GameViewController" bundle:nil];
并在最后发布
[self.navigationController pushViewController:gameViewController animated:YES];
[gameViewController release];
答案 1 :(得分:1)
每次单击该按钮,您都会创建一个新的gameViewController并将其推送到self.navigationController。
你不想每次都换一个新的。