in iOS 17, I found the function [compareDate:toDate:toUnitGranularity] in NSCalendar always return “same” here is the code :
NSString *transformedFromDateStr = "2023-06-16";
NSString *transformedToDateStr = "2023-06-20";
NSDate *transformedFromDate = [NSDate dateWithString:transformedFromDateStr formatString:@"yyyy-MM-dd" timeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
NSDate *transformedToDate = [NSDate dateWithString:transformedToDateStr formatString:@"yyyy-MM-dd" timeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
NSCalendarUnit uint = NSCalendarUnitDay;
NSCalendar *calendar = [NSCalendar currentCalendar];
calendar.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
//the result always return true
NSComparisonResult result = [calendar compareDate:transformedFromDate
toDate:transformedToDate
toUnitGranularity:uint];
now before iOS 17 is right, why this happened ?