PavanAlapati
PavanAlapati

Reputation: 39

prepareforSegue method on UITableViewControllers

I used two tableviewcontrollers,i want to display country names array data in first tableviewcontroller (recipeBookTableViewController) and other capital array data in second tableviewcontroller (RecipetableviewController), when a first tableviewcontroller cell is clicked it should move to second tableviewcontroller with capital array data.

I have taken prepareforSegue method to shift to second tableview. but the method is never called.
how to send data to next tableview.

RecipeBookViewController(table1)            Recipetableview(table2)
  INDIA (cell)                    ------------>      Delhi(cell)



- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{
   if ([segue.identifier isEqualToString:@"showRecipeDetail"]) 
   {
      NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];


      RecipeDetailViewController *destViewController = segue.destinationViewController;
      destViewController.second = [onew objectAtIndex:indexPath.row];
      NSLog(@"%@",onew);
      NSLog(@"data is %@",destViewController.second);
      //  destViewController.lable2 = [derivationArray objectAtIndex:indexPath.row];
      //  destViewController.image = [iconArray objectAtIndex:indexPath.row];


   }
}

Upvotes: 0

Views: 79

Answers (1)

Preetam Jadakar
Preetam Jadakar

Reputation: 4561

Problem is in creating segue.

Make sure you have created segue from cell of first table to second viewController.

Name the segue as showRecipeDetail.

Look at the image below: enter image description here

Upvotes: 2

Related Questions