gpt4 book ai didi

ios - 快速比较 NSDates

转载 作者:行者123 更新时间:2023-11-28 11:20:16 24 4
gpt4 key购买 nike

我有两个 NSDate 对象,我想将其与以下代码进行比较:

    var endDate = self.object.endDate
var thisDate = NSCalendar.currentCalendar().dateFromComponents(currentComponents)

let test = thisDate?.compare(endDate) == NSComparisonResult.OrderedDescending

do {
timeRangeArray.addObject(thisDate!)
currentComponents.minute += 15
thisDate = NSCalendar.currentCalendar().dateFromComponents(currentComponents)
} while thisDate?.compare(endDate) == NSComparisonResult.OrderedDescending {
return timeRangeArray
}

并且总是得到 - (() -> () -> $T8) -> $T9 is not identical to NSComparsionResult

我不想为 while 语句创建另一个值,有没有其他方法可以让它工作?

最佳答案

A do-while statement看起来像这样:

do {
statements
} while condition

你的看起来像这样:

do {
statements
} while condition {
// what is this???
}

我想你的意思是:

do {
timeRangeArray.addObject(thisDate!)
currentComponents.minute += 15
thisDate = NSCalendar.currentCalendar().dateFromComponents(currentComponents)
} while thisDate?.compare(endDate) == NSComparisonResult.OrderedDescending

return timeRangeArray

关于ios - 快速比较 NSDates,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28835812/

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