Reputation: 875
I'm porting a fairly simple iPhone Navigation based app to a Split View iPad app. I have two nested levels of navigation on the Master view. The user picks a value from the first table and it loads the 2nd table. Selecting a value on the second table loads the Detail item for the detail view. I've (finally) gotten that part working.
When I try to pull up the Master view again, though, whether using the popover menu button in portrait or just navigating back to it and clicking on a record in landscape view, it crashes with a GDB: Program received signal: "EXC_BAD_ACCESS" error. I can't find anyplace in the code to step into to identify the problem.
I'm following the SplitView template fairly closely. I'm only really getting off the beaten track by adding that 2nd TableViewController. My RootViewController loads the 2nd TableViewController.
Here's the code:
First, in RootViewController.m I'm loading the 2nd TableView when an item is selected on the 1st (in didSelectRowAtIndexPath):
RequestsTableViewController *requestsTableViewController=[[RequestsTableViewController alloc] initWithNibName:@"RequestsTableViewController" bundle:nil];
requestsTableViewController.selectedDepartmentID = self.selectedDepartmentID;
[self.navigationController pushViewController:requestsTableViewController animated:YES];
[requestsTableViewController release];
Then, in the 2nd TableViewController, RequestsTableViewController, I load the detail item based on its selection in didSelectRowAtIndexPath:
TrackerSplitViewAppDelegate *appDelegate = (TrackerSplitViewAppDelegate *)[[UIApplication sharedApplication] delegate];
Request *aRequest = [appDelegate.requests objectAtIndex:indexPath.row];
appDelegate.detailViewController.thisRequest = aRequest;
appDelegate.detailViewController.detailItem = [NSString stringWithFormat:@"Row %d", indexPath.row];
[appDelegate release];
The app loads and sets my values and everything is working fine. I can navigate between the two TableViewControllers just fine with the auto-generated navigation as long as I don't click on a detail. Once I click on a detail and it's loaded, though, I crash the app if I try to re-access the MasterView. I did nothing to the nib files to wire this navigation up, it all worked ported from the iPhone app (other than this crash). I can't find any examples with multiple master views to see where my wire up is different. I suspect I have to tweak something in the interface builder or something, but as I can't tell exactly where it's crashing, I'm having a hard time getting started. Or do I just need to push the original view back on to the stack programmatically after a detail has been selected? That seems ham-fisted.
Upvotes: 1
Views: 757
Reputation: 90117
[appDelegate release];
You should not release the appDelegate unless you've retained it. And you haven't done this. So get rid of this line.
Upvotes: 3