-(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
views:
96answers:
2
+1
A:
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.
Anon.
2010-02-03 22:43:34
how do i do that?
Steve
2010-02-03 22:44:54
Make `gameViewController` an ivar (instance variable) with properties and reference it as `self.gameViewController`.
Alex Reynolds
2010-02-03 23:47:46
+2
A:
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];
Joe Cannatti
2010-02-03 22:46:21