Hi all -
I'm using a pretty standard recipe for presenting ModalViewControllers in my iPhone apps, but I've run across a situation where the recipe is broken and I'm confused. This is how I (pretty much always) set up the presentation:
MatcherViewController *controller = [[MatcherViewController alloc] initWithNibName:@"MatcherView" bundle:nil];
[controller setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[controller setDelegate:self];
[self presentModalViewController:controller animated:YES];
[controller release];
This always works great until I added one thing to the mix, and I sent a message to the new controller object before I presented it, like so:
MatcherViewController *controller = [[MatcherViewController alloc] initWithNibName:@"MatcherView" bundle:nil];
[controller setPrimary:primaryIndex andSecondary:secondaryIndex];
[controller setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[controller setDelegate:self];
[self presentModalViewController:controller animated:YES];
[controller release];
Adding this method call seems to work until I dismiss the view controller...at which point the app crashes with an EXEC_BAD_ACCESS signal. I can get it to work with the extra line if I remove [controller release]
, but then I'm afraid that will cause a leak. Any ideas why sending a message to the object prior to presentation would cause this? Is there a better way to pass simple parameters up to the ModalViewController?
Thanks for your time in straightening out the newbie ;p