This is my first time comparing dates in Objective-C. I’ve been searching the web for a while and all the examples I found involve building a NSDate from a string so I decided to ask a new question here…
My question is as follows:
I need to know if two NSDates are in the same day, ignoring the time. I got two NSArray‘s containing a set of dates and one by one I need to determine which one from the first NSArray is in the same day as in the second array.
- (void)setActiveDaysColor:(UIColor *)activeDaysColor
{
for (DayView *actualDay in _days)
{
NSDate *actualDayDate = [actualDay date];
for (NSDate *activeDayDate in self.dates)
{
// Comparison code
// If both dates are the same, tint actualDay with a different color
}
}
}
Thank you in advance and have a nice day.
Alex.
create new dates by omitting the time components. and use one of the compare methods
example