0

I have a tableView wich displays content from an array with objects. But the tableview have sections for each date, and I get the same content in all the sections. I guess NSDictionary *object = [array objectAtIndex:indexPath.row]; returns the row for the section and not for the total array. How can I get the row count for the whole tableView? Or is it some other way to do it?

4

1 回答 1

1
int rowsOffset = 0;
for (int section; section ++; section < indexPath.section) {
  rowsOffset += [[[titles objectAtIndex:section] objectForKey:@"Values"] count];
}

NSDictionary *object = [array objectAtIndex:indexPath.row+rowOffset];

可能更好:

NSArray *theArray = [[titles objectAtIndex:indexPath.section] objectForKey:@"Values"];
NSDictionary *object = [theArray objectAtIndex:indexPath.row];
于 2012-09-25T13:33:36.577 回答