偶尔会用到,记一下关键字省的以后还要随时去网上找
//比较两个日期的大小
+ (BOOL)compareDate:(NSDate*)stary withDate:(NSDate*)end
{
NSComparisonResult result = [stary compare: end];
if (result==NSOrderedSame)
{
//相等
return: NO;
}else if (result=NSOrderedAscending)
{
//结束时间大于开始时间
return:YES;
}else if (result=NSOrderedDescending)
{
//结束时间小于开始时间
return:NO;
}
return NO;
}
基本上记住NSComparisonResult result = [stary compare: end];
就可以了
然后记住
NSOrderedSame
NSOrderedAscending
NSOrderedDescending
还有其他以后补充,临时用到这个就记一下