views:

34

answers:

1

hi guys,

i am writing a little music-game for the iphone. I am almost done, this is the only issue which keeps me from rolling it out. any help to solve this is much appreciated.

this is what i do: at my appDelegate I add my menu-view-screen to the window. the menu-view-screen acts as a container and controls which view gets presented to the user.

means, on the menu-view-screen I got 4 buttons (new game, options, faq, highscore). when the user clicks on a button something as this happens:

 if (self.gameViewController == nil)
 {
  GameViewController *viewController = [[GameViewController alloc] initWithNibName:@"GameViewController" bundle:nil];
  self.gameViewController = viewController;
  [viewController release];
 }
 [self.view addSubview:self.gameViewController.view];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleSwitchViewNotificationFromGameView:) name:@"SwitchView" object:gameViewController];

when the user returns to the menu, this piece of code gets executed:

 [[NSNotificationCenter defaultCenter] removeObserver:self];
 [self.gameViewController viewWillDisappear:YES];
 [self.gameViewController.view removeFromSuperview];

this works fine for all screens but not for the gamescreen(well this is the only one with heaps of user-interaction) means the responsiveness of the iphone(when playing tones) gets really slow. The performance is fine when I display the gameview for the first time. it starts getting slower as soon as I add it to the menu-views-container-subviews again (addsubview) (basically open up a new game) any ideas what causes(or to get around) this?

thanks heaps

Best regards Tom

A: 

Ok, off the top of my head this doesn't sound like a controller issue. It sounds like an issue with something else being left running or chewing up memory. I'd suggest using the profiling tools to see if you can pin point where the CPU is disappearing too. You might have a memory leak of objects which are also doing lots of stuff for example.

Derek Clarkson