Saturday, 22 August 2015

NSArray subsets and sorting from a dynamic categoryArray


i've run big question of approach in order fuel graph view.

retrieve arrays via coredata.

category <--->>entry entity relationship exists.
code:
category <-------->>entry  
i need combine results of category <-->> entry relationship array sorted nsdate, thats pretty easy, parent have multiple entries based on timestamp (nsdate) of adding it.

use fetchrequest following:

code:
    nssortdescriptor *sortdescriptor = [[nssortdescriptor alloc] initwithkey:@"timestamp" ascending:no];      nsarray *sortdescriptors = [[nsarray alloc] initwithobjects:sortdescriptor, nil];    
want have combined result thats sorted based on timestamps

example,

code:
    nsarray result_cata = [entries sortedby timestamp]; {a0 ,a1, a2, a3,     a5}   (5)      nsarray result_cattb = [entries sortedby timestamp]; {b0, b1, b2, b3, b4}       (5)      nsarray result_catc = [entries sortedby timestamp]; {c0, c1, c2, c3, c4  c5 }  (6)
two points note here,
1- array result_cata has no entryobject on date "4th" , likewise, b array has no entry on "5th", lets assume digits nsdates of adding.

want have array gives me result array like:

code:
    combinedsortedarray objectatindex:0] = array{a0, b0, c0}  countremains 3       combinedsortedarray objectatindex:1] = array{a1, b1, c1}  count remains 3      combinedsortedarray objectatindex:4] = array{0.0, b4, c4}      combinedsortedarray objectatindex:5] = array{a5, 0.0, c5}      //count of subset arrays remains 3  equal count of parents! difference being nil result replaced 0.0!  

2- more complicated knowing category dynamic number, there total number of 4 categories presented, in case there 4 arrays parse one, , each object of single sorted array have 4 object count.

im clueless now, appreciated.
 



Forums iPhone, iPad, and iPod Touch iOS Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment