1

My NSManagedObject has a property NSDate with format: 2012-03-27 14:43:22 +0000. I want to sort my results by date, so I do: NSSortDescriptor *sort= [[NSSortDescriptor alloc] initWithKey:@"createDate" ascending:NO selector:@selector(compare:)];

And I separate into sections using sectionNameKeyPath: NSFetchedResultsController *theFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:appDelegate.managedObjectContext sectionNameKeyPath:@"createDate" cacheName:nil];

However, I want to sort by days, not by exact date. Currently, if I have two createDates of the same day but seconds apart, they are sorted into separate sections. I want to sort all objects with the same day into the same section. How would I do this?

Snowman
  • 31,411
  • 46
  • 180
  • 303
  • found a similar question here: [Sort NSDate without respect to the time of day - just the date][1] [1]: http://stackoverflow.com/questions/8651733/sort-nsdate-without-respect-to-the-time-of-day-just-the-date – fengd Mar 30 '12 at 03:11

2 Answers2

1

Just a rough thought. You can store the date with string "2012-03-27", I think you can sort them by days.

yibuyiqu
  • 728
  • 1
  • 7
  • 20
0

Here's two posts that I came across the other day that discuss non-standard sections. It will give you a few cool directions and ideas:

Using custom sections with NSFetchedResultsController?
Group by weekdays with Core Data

Community
  • 1
  • 1
Gobot
  • 2,464
  • 1
  • 21
  • 26