While doing some tests on my old iPhone 4 (iOS 7.1.2) I encountered an error performing a segue from my initial collectionView to a tableView.
Everything works fine on iOS 8, but I get the following error on iOS 7:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ListaPlatosTableViewController topViewController]: unrecognized selector sent to instance 0x17df3c70'
My prepareForSegue method is the following:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
UINavigationController *nav = [segue destinationViewController];
ListaPlatosTableViewController *listaPlatosVC = (ListaPlatosTableViewController *)nav.topViewController;
[listaPlatosVC setPlatosCarta:platosCarta];
//I have set selectedCell in the method where I call performSegueWithIdentifier
[[[segue destinationViewController]topViewController]setTitle:selectedCell];
}
//UPDATE: Here's the code that calls the segue, in case I'm overlooking something
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
selectedCell = [tiposCarta objectAtIndex:indexPath.row];
[self ponerPlatosEnCarta]; // I prepare platosCarta with this method
[self performSegueWithIdentifier:@"ListaPlatos" sender:self];
}
has anyone encountered this?
Then have a segue to
topViewControlleris a property of a navigation controller, not a table view controller, so the segue should point to a navigation controller for your code to work. If the same storyboard is used then the code should work or fail in both cases, you need to debug in both cases to see what's happening. - Wain