objective c - One Array - Multiple sections - NSIndexPath -
i have 1 big array many values. i've sorted out sections can't seem indexpath right.
basically, i'm trying do, if previous section has 50 rows, next indexpath.row should 51->. 1 after should 60-> , fourth.
nslog(@"current indexpath.row: %ld",(long)indexpath.row); nslog(@"current section: %ld",(long)indexpath.section); (int = indexpath.section; == indexpath.section; i++) { nslog(@"number of rows: %ld",(long)[self tableview:tableview numberofrowsinsection:indexpath.section]); nslog(@"in section: %ld",(long)indexpath.section); if (i++) { // add previous number of rows plus current int previousrows = [self tableview:tableview numberofrowsinsection:indexpath.section*2]; nslog(@"now indexpath: %ld",(long)previousrows+indexpath.row); } }
i hope i've made question clear enough understand.
nsindexpath
doesn't work way. nsindexpath
starts 0 every section.
if understand correctly, want know global index value access array. case, have been using little method:
- (int)getglobalrowfor:(int)row at:(int)section { if(section == 0) { return row; } else { int count = 0; for(int = 0; < section; i++) { // put own numbers section counts. // model, yours different. count += [[[self.sections objectatindex:i] objectforkey:@"sectioncount"] intvalue]; } return count + row; } }
Comments
Post a Comment