我有两个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语句创建另一个值,还有其他方法可以让它工作吗?
答案 0 :(得分:3)
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