Now I have a 1-dimonsion NSArray, each element of which is a NSMangedObject with a NSDate Attribute,
for example
an event Entity has an date(NSDate) attribute and name(NSString) attribute.
So the initilized array should be like this:
(NSArray) Events: event1, event2, event3,…,nil
Now, I need to group these objects by their date so that I can make this array the data source of a sectioned tableView.
And I just need the elememts in a same section have the same date, here the date means year,month,day, and with no hour or minute.
So the grouped NSArray should be a 2-dimension array, such as:
(NSArray) Events: day1, day2, day3, day4,…,nil;
and here day1,day2… are also a NSArray, and inside of them are really event objects. like this:
(NSArray) day1: event1, event2, event3, …, nil;
So how can I realize this ?
I guess I can not use NSFetchedResultsController, since actually I have to fetch several entities, each of which has a NSDate attribute, and put them together to be grouped by date.
and I believe there’s no problems about fetching,
I jus wonder how can I transfer the fetched 1-dimension array into the date-based 2-dimension array that I need?
Hoping someone to help and thanks very very much for answering!
You can use a custom
NSValueTransformerto convert your entities’ dates to ranges (or days). From there, you can use bindings with that if you like.