My main UIViewController, (PMGameViewController.h), is the file which my apps delegate calls.
There are several buttons on my main UIViewController (PMGameViewController.m). When a button is pressed I do an insertSuvbiew and attach another UIViewController on top. When the mini game is over I simply do a removeFromSubview. This removes the UIViewController I inserted on top and shows me the main menu. Perfect this is what I want, but...
After I do a removeFromSubview, the objectalloc does not drop. How can I release that UIViewController's memory. I do not know of a way to backreference to my main UIViewController (PMGameViewController.m) to tell it that it has been removed and to release the UIViewController memory.
Here is how I insert the Subview
//////////////////////////////////////
//Buttons are in PMGameViewController.m file
//////////////////////////////////////
if((UIButton *) sender == gameClassicBtn) {
//////////////////////////////////////
//This Inserts the GameClassic.h file
//////////////////////////////////////
GameClassic *gameClassicController = [[GameClassic alloc]
initWithNibName:@"GameClassic" bundle:nil];
self.gameClassic = gameClassicController;
[gameClassicController release];
[self.view insertSubview:gameClassicController.view atIndex:1];
}
if((UIButton *) sender == gameArcadeBtn) {
//////////////////////////////////////
//This Inserts the GameArcade.h file
//////////////////////////////////////
GameArcade *gameArcadeController = [[GameArcade alloc]
initWithNibName:@"GameArcade" bundle:nil];
self.gameArcade = gameArcadeController;
[gameArcadeController release];
[self.view insertSubview:gameArcadeController.view atIndex:1];
}