iphone - sorted my nsmutabledictionary -


what code sorted dictionary :

{         "a) saudi arabia" =     (             "2012/06/04 huge sandstorm",             "2011/03/30 huge sandstorm"         );         "b) niger" =     (             "2012/05/27 huge sandstorm"         );         "c) ****** quatre" =     (             "2011/03/30 7huge sandstorm on niger",             "2011/03/30 8huge sandstorm on niger",         );     } 

for uitableview ?

with code titles header section in order not content:

- (nsstring *)tableview:(uitableview *)tableview titleforheaderinsection:(nsinteger)section {     nsarray *allkeys = [[states allkeys] sortedarrayusingselector:@selector(compare:)];     return [allkeys objectatindex:section]; }  - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     static nsstring *cellidentifier = @"cell";            uitableviewcell *cell = (uitableviewcell *) [tableview dequeuereusablecellwithidentifier:cellidentifier];      if (cell == nil) {         cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:cellidentifier];                }      nsarray *allkeys = [states allkeys] ;     nsstring *curkey = [allkeys objectatindex:indexpath.section];     nsarray *curarray = [states objectforkey:curkey];     curvalue = [curarray objectatindex:indexpath.row];      cell.textlabel.text = curvalue;      cell.accessorytype = uitableviewcellaccessorydisclosureindicator;        [[cell textlabel] setfont:[uifont systemfontofsize:12.0]];     return cell;   } 

someone can please me?

//use code

 - (nsinteger)numberofsectionsintableview:(uitableview *)tableview  {      return [[states allkeys] count];//returns number of key/object pairs  }   - (nsstring *)tableview:(uitableview *)tableview titleforheaderinsection:(nsinteger)section  {       nsarray *allkeys = [[states allkeys] sortedarrayusingselector:@selector(compare:)];       return [allkeys objectatindex:section];   }    - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section     {        nsarray *allkeys = [[states allkeys] sortedarrayusingselector:@selector(compare:)];        nsstring *curkey = [allkeys objectatindex:section];        nsarray *curarray = [states objectforkey:curkey];         return [curarray count];      }       - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath     {           static nsstring *cellidentifier = @"cell";             uitableviewcell *cell = (uitableviewcell *) [tableview dequeuereusablecellwithidentifier:cellidentifier];       if (cell == nil) {          cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:cellidentifier];       }      // configure cell...       //---------- cell background image -----------------------------      uiimageview *imageview = [[uiimageview alloc] initwithframe:cell.frame];      uiimage *image = [uiimage imagenamed:@"lightgrey.png"];      imageview.image = image;      cell.backgroundview = imageview;      [[cell textlabel] setbackgroundcolor:[uicolor clearcolor]];       [[cell detailtextlabel] setbackgroundcolor:[uicolor clearcolor]];        nsarray *allkeys = [[states allkeys] sortedarrayusingselector:@selector(compare:)];       nsstring *curkey = [allkeys objectatindex:indexpath.section];     nsarray *curarray = [[states objectforkey:curkey]     sortedarrayusingselector:@selector(compare:)];      nsstring *curvalue=@"";      if([curarray count]>indexpath.row)           curvalue = [curarray objectatindex:indexpath.row];     if(curvalue)        cell.textlabel.text = curvalue;       cell.accessorytype = uitableviewcellaccessorydisclosureindicator;       [[cell textlabel] setfont:[uifont systemfontofsize:12.0]];      return cell;   }    - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath{       return 60;     } 

may you


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -