gpt4 book ai didi

ios - NSDate。抓取今天之前的所有日期

转载 作者:行者123 更新时间:2023-11-29 10:56:35 25 4
gpt4 key购买 nike

我正在尝试使用这个 calendar component我的任务是在今天之前的所有日期在视觉上和技术上使残疾人成为残疾人。用户也可以在月份之间切换,我需要禁用今天之前的所有日期,即使它是几年前的日期。 disabledDateTextColordisabledDateBackgroundColor 类型也为此日历定义,但没有日期计算方法。我正在阅读 NSDate 文档,看起来我不能直接这样做,使用系统方法(我的意思是方法返回日期之前或之后的日期数组或类似的东西)。看起来像将今天之前的所有现有日期添加到 NSArray 并在绘制日历之前将它们标记为禁用是一个明显的矫枉过正,不是吗?

最佳答案

在我之前的申请中我使用了这个方法

switch ([dateOne compare:dateTwo]) {
case NSOrderedAscending:
// dateOne is earlier in time than dateTwo
break;
case NSOrderedSame:
// The dates are the same
break;
case NSOrderedDescending:
// dateOne is later in time than dateTwo
break;
}

两个日期格式应该是相似的阅读下面链接中的实例方法以获取更多信息

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/Reference/Reference.html#//apple_ref/occ/instm/NSDate/compare :

关于ios - NSDate。抓取今天之前的所有日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17991361/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com