The user can select/deselect cells in each section, so to track all the selected cells in the didSelectRowAtIndexPath is not useful:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"row = %i, section = %i", indexPath.row, indexPath.section);
}
What i want instead is to save time and resources, so to let the user check/uncheck whatever he wants, and when he click on a button (to go to next view), i need to collect all selected cells in the whole table view. I tried to do like this:
-(IBAction)nextView:(id)sender{
themesChoosed=[self.tView indexPathsForSelectedRows];//tView is the outlet of my UITableView and themesChosed is an NSArray declared in the .h file
for (int i=0; i<=[themesChoosed count]; i++) {
NSIndexPath *thisPath = [themesChoosed objectAtIndex:i];
NSLog(@"row = %i, section = %i", thisPath.row, thisPath.section);
}
}
But this doesn’t return me the selected cells, it shows me always: row = 0, section = 0 as if i am only selecting the first cell in the first section.
Any thoughts on how to do so?
Take in .h file
in .m