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

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

wso2esb - How to concatenate JSON array values in WSO2 ESB? -