ios - How to sort UITableView sections -


i have array of objects date inside. need group objects in uitableview date. examle:

0-{10-14; obj1}; 1-{10-14; obj2}; 2-{10-15; obj3}; 3-{10-15; obj4}; 

i need view on uitableview this

10-14     0-{10-14; obj1};     1-{10-14; obj2}; 10-15     2-{10-15; obj3};     3-{10-15; obj4}; 

to resolve i've done next; i've splited array nsdictationary code:

nsmutabledictionary *preresult = [[nsmutabledictionary alloc] init]; (clientmessage *message in array) {     nsmutablearray *marray = [preresult objectforkey:message.formatteddate];     if (marray == nil) {         marray = [[nsmutablearray alloc] init];         [preresult setobject: marray forkey:message.formatteddate];     }     [marray addobject:message]; } 

and table view shows me want, shows in wrong order; (my array sorted date) know tha can't sort nsdictationary, in case how can sort values in table view? or there way group values without nsdictationary?

once you've finished loading dictionary values, you'll want sort each array within dictionary...

for (nsstring *key in [preresult allkeys]) {     nsmutablearray *marray = [preresult objectforkey:key];       // sort array achieve desired result     nssortdescriptor *sortdescriptor = [[nssortdescriptor alloc] initwithkey:@"formatteddate" ascending:yes];     nsarray *sortedarray = [marray sortedarrayusingdescriptors:@[sortdescriptor]];       // reset newly sorted array key inside dictionary     [preresult sortedarray forkey:key]; } 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -