0

I have to compare many managed objects and group them by date. I can't use NSDateComponents because it's too slow to compare two NSDate objects.

How can I compare them in a more efficient way, so that I can save processing time?

Chris Forrence
  • 10,042
  • 11
  • 48
  • 64
ashvardanian
  • 424
  • 1
  • 6
  • 17

1 Answers1

2

I am not sure what kind of comparison you are doing but you can do:

if ( [date1 timeIntervalSince1970] > [date2 timeIntervalSince1970])
{
    NSLOG(@"Do something");
}

so if date1 is bigger (further away for 1970!) than date2 the if is true. This will work quicker than NSDateComponents.

Will Johnston
  • 864
  • 4
  • 18