I have a UITableView with multiple sections. Instead of the typical approach of using an array per section, I am using one array. Anyway, I am having trouble getting the current indexPath.row as if there was only one section in the tableview.
So pretty much what I am trying to do is as follows. If the section == 0, I just use the indexPath.row, but if the section > 0, I want to add up all the rows from the previous section and get the current row in the current section to get the total row number AS IF THE TABLEVIEW WAS ONLY ONE SECTION.
This is my current code and it just isn't working out, perhaps you guys will see what I am doing wrong. Please let me know:
if (indexPath.section == 0) {
currentRow = indexPath.row;
} else {
NSInteger sumSections = 0;
for (int i = 0; i < indexPath.section; i++) {
int rowsInSection = [activitiesTable numberOfRowsInSection:i] + 1;
sumSections += rowsInSection;
}
NSInteger row = [NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section].row + 1;
currentRow = sumSections + row;
}