Search code examples
uitableviewcallsegueviewcontroller

calling another ViewController on row selection in TableViewController


I am using UITableViewController and on selection of row from the list i want to open another scene and send the info of the selected row. I got one link and i followed that and also i attched say Segue1 to segue2 in push mode. but when i am executing it is throwing error for no such segue associated with segue1.

below is the code for Row Selection:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    NSLog(@"index is %ld",(long)indexPath.row );
    [self performSegueWithIdentifier:@"Put_Controller" sender:indexPath.self];



}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"Put_Controller"]) 
    {
        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        NSDate *object = _objects[indexPath.row];
        [[segue destinationViewController] setDetailItem:object];
    }
}

Solution

  • Don't forget to set storyboard segue identifier:- Put_Controller enter image description here