Reputation: 573
Using storyboards I have a table view controller with a list of rows. When a row is selected, I want to pass the data associated with that row across to another table view controller which is embedded within an UINavigationController.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"EditJob"])
{
NewJobsTableViewController *newJobsTableViewController = segue.destinationViewController;
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
Jobs *job = [self.fetchedResultsController objectAtIndexPath:indexPath];
newJobsTableViewController.jobDetails = job;
}
}
On the last line within the prepareForSegue method I am getting the following error:
[UINavigationController setJobDetails:]: unrecognized selector sent to instance 0x83a7780
2012-11-11 08:50:25.335 My Trades[40612:c07] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationController setJobDetails:]: unrecognized selector sent to instance 0x83a7780'
jobDetails is declared in the newJobsTableViewController as:
@interface NewJobsTableViewController : UITableViewController <UITextFieldDelegate, NSFetchedResultsControllerDelegate> {
Jobs *_jobDetails;
}
@property (strong, nonatomic) Jobs *jobDetails;
I am not sure why it's causing this error.
Upvotes: 0
Views: 262
Reputation: 104092
It sounds to me like you set up your storyboard wrong. That second tableViewController shouldn't be embedded in its own navigation controller. Just set up a push segue from your first tableViewController to the second -- the second will automatically be embedded in the same navigation controller as the first one.
The reason for the error, I think, is because the destination view controller is actually the navigation controller that you embedded the second view controller in. This line doesn't do what you expect it to do:
NewJobsTableViewController *newJobsTableViewController = segue.destinationViewController;
Even though you're setting the return value of destinationViewController to your class, it will return whatever it actually is -- I'm betting that if you log the class of newJobsTableViewController, it will actually come back as UINavigationController.
Upvotes: 1