0

A few hours ago this code gave me no problems, however, after updating my XCode my XCode and removing a 3rd party framework, it is suddenly giving me the above exception. I'm extremely confused because I don't think anything's changed between then and now that could cause the problem besides updating my XCode. Can anyone see an issue?

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

/*We check to make sure the segue corresponds to segue we created when a cell is selected*/
if ([[segue identifier] isEqualToString:@"show"]) {

   /*Get a pointer to the selected row*/
    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];

    /*Get a pointer to the ViewController we will segue to*/
    ViewController *viewController = segue.destinationViewController;

    /*Pass the dialect and code back to the ViewController*/
   viewController.language = self.languages.allKeys[indexPath.row];
    viewController.code = [self.languages objectForKey:viewController.language];

  }
}

Specifically, the following two lines are causing the exception:

viewController.language = self.languages.allKeys[indexPath.row];
viewController.code = [self.languages objectForKey:viewController.language];
planner15
  • 53
  • 8
  • possible duplicate of [How can I debug 'unrecognized selector sent to instance' error](http://stackoverflow.com/questions/25853947/how-can-i-debug-unrecognized-selector-sent-to-instance-error) – Hot Licks Mar 10 '15 at 19:16

1 Answers1

4

Your segue's destination controller is a UINavigationController, your view controller is likely the top view controller of that navigation controller. You probably want:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    /*We check to make sure the segue corresponds to segue we created when a cell is selected*/
    if ([[segue identifier] isEqualToString:@"show"]) {

    /*Get a pointer to the selected row*/
    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];

    UINavigationController *navController = segue.destinationViewController

    /*Get a pointer to the ViewController we will segue to*/
    ViewController *viewController = navController.topViewController;

    /*Pass the dialect and code back to the ViewController*/
    viewController.language = self.languages.allKeys[indexPath.row];
    viewController.code = [self.languages objectForKey:viewController.language];
  }
}
dan
  • 9,695
  • 1
  • 42
  • 40