Swift3 Swift 3中的稍后日期
我想转换成Swift 3语法。我们检查的起始日期是晚些时候。请帮忙。如有任何帮助,我们将不胜感激Swift3 Swift 3中的稍后日期,swift3,Swift3,我想转换成Swift 3语法。我们检查的起始日期是晚些时候。请帮忙。如有任何帮助,我们将不胜感激 while (startDate.laterDate(endDate) != startDate) 我要胡乱猜测你想要什么,因为你不是很清楚。这是你想要的吗 while (startDate < endDate) { ... while(开始日期
while (startDate.laterDate(endDate) != startDate)
我要胡乱猜测你想要什么,因为你不是很清楚。这是你想要的吗
while (startDate < endDate) {
...
while(开始日期<结束日期){
...
Swift 3/4的扩展:
愚蠢的版本
稍微不那么傻的版本(还是更傻?)
extension Date {
func later(_ otherDate: Date) -> Date {
return (self as NSDate).laterDate(otherDate)
}
}
extension Date {
func later(_ otherDate: Date) -> Date {
switch self.compare(otherDate) {
case .orderedAscending:
return otherDate
default:
return self
}
}
}