Can this part of a view controller subclass be checked for memory leaks. I am not that good at finding leaks. I need this class to be able to be loaded many time over without it crashing due to memory leaks. The endgame gets called every time it needs to go back to the main menu. I want it to be able to go back to the main menu without leaving any memory footprint.
UIImageView* questionImage;
UIImageView* questionImage2;
UIButton* questionButton1;
UIButton* questionButton2;
UIButton* questionButton3;
UIButton* questionButton4;
UIButton* questionButton5;
UIButton* questionButton6;
UIButton* achievementbutton;
UIButton* endbutton;
UILabel* questionText;
UILabel* ButtonLabel;
- (void)viewDidLoad
{
[super viewDidLoad];
[self StartTimer];
TotalSeconds = 0;
GameCenterTotalSeconds = 0;
timeSec = 0;
timeMin = 0;
Background = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 480, 320)] ;
Background.image = [UIImage imageWithContentsOfFile:[ [ NSBundle mainBundle] pathForResource:@"Background" ofType:@"png"]];
[self.view addSubview:Background];
timeLabel.textColor = [UIColor redColor];
[self.view addSubview:timeLabel];
NumberLabel = [[UIImageView alloc] initWithFrame:CGRectMake(0, -4, 60, 70)] ;
NumberLabel.image = [UIImage imageWithContentsOfFile:[[ NSBundle mainBundle] pathForResource:@"Number" ofType:@"png"]];
[self.view addSubview:NumberLabel];
QuestionNumber = [[UILabel alloc] initWithFrame:CGRectMake(23, 17, 20, 20)] ;
QuestionNumber.text = @"1";
QuestionNumber.textColor = [UIColor redColor];
QuestionNumber.backgroundColor = [UIColor clearColor];
[QuestionNumber setFont:[UIFont fontWithName:@"Marker Felt" size:30]];
[self.view addSubview:QuestionNumber];
numberLives = 1;
appDelegate = (OppositeMoronTestAppDelegate *)[[UIApplication sharedApplication]delegate];
musicButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain] ;
musicButton.frame = CGRectMake(5, 283, 35, 35);
musicButton.backgroundColor = [UIColor clearColor];
if (appDelegate.shouldPlayMusic == YES) {
UIImage *Image = [UIImage imageWithContentsOfFile:[[ NSBundle mainBundle] pathForResource:@"MusicOn" ofType:@"png"]];
[musicButton setBackgroundImage:Image forState:UIControlStateNormal];
[musicButton addTarget:self action:@selector(TurnMusicOff) forControlEvents:UIControlEventTouchUpInside];
} else {
UIImage *Image = [UIImage imageWithContentsOfFile:[[ NSBundle mainBundle] pathForResource:@"MusicOff" ofType:@"png"]];
[musicButton setBackgroundImage:Image forState:UIControlStateNormal];
[musicButton addTarget:self action:@selector(TurnMusicOn) forControlEvents:UIControlEventTouchUpInside];
}
[self.view addSubview:musicButton];
[self showQuestion1];
}
- (void) showQuestion1
{
questionImage = [[UIImageView alloc] initWithFrame:CGRectMake(15, 50, 430, 270)] ;
questionImage.image = [UIImage imageWithContentsOfFile:[[ NSBundle mainBundle] pathForResource:@"Q1new" ofType:@"png"]];
[self.view addSubview:questionImage];
questionButton5 = [UIButton buttonWithType:UIButtonTypeCustom];
[questionButton5 addTarget:self action:@selector(showQuestion2Part1)forControlEvents:UIControlEventTouchDown];
questionButton5.frame = CGRectMake(109, 75, 90, 65);
[self.view addSubview:questionButton5];
questionButton1 = [UIButton buttonWithType:UIButtonTypeCustom];
[questionButton1 addTarget:self action:@selector(wronganswer)forControlEvents:UIControlEventTouchDown];
questionButton1.frame = CGRectMake(230, 50, 120, 90);
[self.view addSubview:questionButton1];
questionButton2 = [UIButton buttonWithType:UIButtonTypeCustom];
[questionButton2 addTarget:self action:@selector(wronganswer)forControlEvents:UIControlEventTouchDown];
questionButton2.frame = CGRectMake(300, 144, 100, 90);
[self.view addSubview:questionButton2];
questionButton3 = [UIButton buttonWithType:UIButtonTypeCustom];
[questionButton3 addTarget:self action:@selector(wronganswer)forControlEvents:UIControlEventTouchDown];
questionButton3.frame = CGRectMake(203, 187, 95, 90);
[self.view addSubview:questionButton3];
questionButton4 = [UIButton buttonWithType:UIButtonTypeCustom];
[questionButton4 addTarget:self action:@selector(wronganswer)forControlEvents:UIControlEventTouchDown];
questionButton4.frame = CGRectMake(67, 140, 120, 95);
[self.view addSubview:questionButton4];
questionText = [[UILabel alloc] initWithFrame:CGRectMake(80, 20, 300, 30)] ;
questionText.text = @"Press the Addition Sign";
questionText.textColor = [UIColor blackColor];
questionText.backgroundColor = [UIColor clearColor];
[questionText setFont:[UIFont fontWithName:@"Marker Felt" size:30]];
[self.view addSubview:questionText];
}
- (void) endgame
{
[WrongBackground release];
[gameOver release];
[wrongLivesLeft release];
[questionImage release];
[questionText release];
[Background release];
[NumberLabel release];
[musicButton release];
[questionImage release];
[questionText release];
[self.view removeFromSuperview];
}