I have this code:
NSComparisonResult compareStart = [firstDate compare: dateSelected];
NSComparisonResult compareEnd = [secondDate compare: dateSelected];
if (((compareStart == NSOrderedAscending) || (compareStart == NSOrderedSame))
&& (compareEnd == NSOrderedDescending))
but it don’t entry in the “if” when firstDate = dateSelected or secondDate = dateSelected…why??
Are you sure that when firstDate equals dateSelected that date selected is earlier than secondDate? Currently your logic is: firstDate <= dateSelected < secondDate. If you want firstDate <= dateSelected <= secondDate, then you need to implement the code as follows:
Update:
To compare two NSDates without relying on time see: Comparing two NSDates and ignoring the time component