Hi all, I am trying to display a modal view controller containing a NavigationController. I can't figure out where to release the controllers, though. Normally, I would just release the controller after displaying it, but that won't work here; presumably that has something to do with the navigation controller. Any help would be great! Here is the code in question:
-(IBAction)displayCreateModifyExerciseViewController:(id)sender {
CreateModifyExerciseViewController *controller = [[CreateModifyExerciseViewController alloc] initWithNibName:@"CreateModifyExerciseView"
bundle:nil];
controller.delegate = self;
controller.title = @"Create Exercise";
UINavigationController *modalNavController = [[[UINavigationController alloc] initWithRootViewController:controller] autorelease];
modalNavController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
controller.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Save"
style:UIBarButtonItemStyleDone
target:controller
action:@selector(done:)];
[self presentModalViewController:modalNavController animated:YES];
//I want to say [controller release];
// [modalNavController release];
//But that causes a crash because controller ends up dealloc-ing.
}