真的很簡單,我相信這是一個很快的bug。我試圖檢查2個NSDates是否相同。這種說法從來沒有通行證甚至以爲打印輸出低於Swift:檢查兩個NSDates是否相同
println("\(statistics.startDate) \(healthObject.date)")
if healthObject.date.isEqualToDate(statistics.startDate)
{
healthObject.flights = Int(quantity.doubleValueForUnit(HKUnit.countUnit()))
println(Int(quantity.doubleValueForUnit(HKUnit.countUnit())))
}
手繪POP練習13時56分50秒+0000手繪POP練習13時56分50秒+0000
手繪POP練習13點56分50秒+0000 2015年3月31日13點56分50秒+0000
2015年3月31日13點56分50秒+0000手繪POP練習13點56分50秒+0000
2015-03-31 13:56:50 +0000 2015-03-31 13:56:50 +0000
解決方案 正如一位真棒人士指出的那樣,日期可能是相同的,直到第二級別。奇怪之處是,在這些值是從HealthKit
什麼在iOS8上對我的作品來爲:
if let dif = calender?.compareDate(statistics.startDate, toDate: healthObject.date, toUnitGranularity: NSCalendarUnit.SecondCalendarUnit)
{
println(Int(quantity.doubleValueForUnit(HKUnit.countUnit())))
println("\(statistics.startDate) \(healthObject.date)")
healthObject.flights = Int(quantity.doubleValueForUnit(HKUnit.countUnit()))
}
剛纔試了很簡單的一個,它似乎有可能只是NSDate的()== NSDate的() – 2015-04-01 14:12:01