Reputation:
I have a page with some segmented controls, text fields and table views. The user writes/selects what he wants and then taps on a button who passes all the values to another view (said values are used to perform a search). This is a semplified version of the function who passes the values:
-(IBAction) doTheSearch {
[self dismissViewControllerAnimated:YES completion:nil];
// initialize the view who will perform the search
NewSearchController *nsc = [[NewSearchController alloc] init];
// set values from one text field and one segmented control
nsc.testString = textfield.text;
NSString *temp = [NSString stringWithFormat:@"%d",segmentedcontrol.selectedSegmentIndex];
nsc.testCode = temp;
[self.navigationController pushViewController:nsc animated:YES];
}
Is it possible to use the same function to get which row(s) is/are selected from the table views, as I do for the text field and segmented control's values?
Upvotes: 1
Views: 560
Reputation: 7474
NSIndexPath *path = [self.tableView indexPathForSelectedRow];
From the above code you can get the indexPath
path.row
to get the exact row you have selected.
Upvotes: 1