I have two TableViewControllers with intergue in between. When a user clicks on a cell in the first TVC, they receive a second TVC. Segue is modal, has an identifier called "segueToLocationDetails" and passes an object with it. You can think of the second TCE as a “detail” more or less.
My code works fine in the above scenario. However, this breaks as soon as I insert the second TVC into the navigation controller.
Example. I work great. Then I highlighted the second TVC in IB, going to Product | Paste in | Navigation controller Now the second TVC is in the Nav controller. However, segue still points to the second TVC. I remove the segue and connect it from the first TVC cell to the navigation controller, and be sure to give the segue identifier. Run again and it breaks! Error below ...
2011-12-23 15: 30: 45.469 Project12 [5219: 11603] - [UINavigationController setDetailsObject:]: unrecognized selector sent to instance 0x7b92ce0 2011-12-23 15: 30: 45.471 Project12 [5219: 11603] * Delete the final expression exception "NSInvalidArgumentException", reason: '- [UINavigationController setDetailsObject:] : unrecognized selector sent instance 0x7b92ce0' * Origin call stack cast: (0x16ea052 0x150ad0a 0x16ebced 0x1650f00 0x1650ce2 0x3933 0x703e1e 0x36f6d9 0x36f952 0xbf786d 0x16be966 0x16be407 0x16217c0 0x1620db4 0x1620ccb 0x14ec879 0x14ec93e 0x2dfa9b 0x2a98 0x29f5 0x1) end call throwing exceptionCurrent language: auto; currently objective-c
Below is the code explaining:
AllLocations.h and AllLocations.m (this is the main table)
AllLocations.h @interface AllLocations : UITableViewController { SQLiteDB *mySQLiteDB; } @property (nonatomic, strong) NSMutableArray *locationsArray; AllLocations.m - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self performSegueWithIdentifier:@"segueToLocationDetails" sender:self]; } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"segueToLocationDetails"]) { NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow]; NSInteger rowNumber = selectedIndexPath.row; mySQLiteDB = (SQLiteDB *) [locationsArray objectAtIndex:rowNumber]; DetailsTVC *detailsTVC = [segue destinationViewController]; detailsTVC.detailsObject = mySQLiteDB; } }
DetailsTVC.h and DetailsTVC.m (this is a detailed view of the table)
DetailsTVC.h @interface DetailsTVC : UITableViewController @property (nonatomic, strong) SQLiteDB *detailsObject; DetailsTVC.m @implementation SpotDetailsTVC @synthesize spotDetailsObject;
Note. I left all the code that was not really important or relevant to the question.
Again: this works fine if segue goes from the original TableVeiwController to another TableViewController. It breaks when I insert a second TVC into the Nav controller. I need to know how to do this with the Nav Controller in the picture. Thanks in advance!