-1
func setTimeLeft() { let timeNow = NSDate() {
if timeEnd.compare(timeNow as Date) == ComparisonResult.orderedDescending {
let calendar = NSCalendar.current
let components = calendar.components([.day , .hour , .minute , .second] , fromDate: timeNow, toDate: timeEnd, options: [])
var dayText = String(components.day) + "d "
var hourText = String(components.hour) + "h "
// Hide day and hour if they are zero
if components.day <= 0 {
dayText = ""
if components.hour <= 0 {
hourText = ""
}
}
timeLeftLabel.text = dayText + hourText + String(components.minute) + "m " + String(components.second) + "s"
} else {
timeLeftLabel.text = "Ended"
}
}
我是新手,我只是停留在這個錯誤 錯誤在行如何解決「沒有更多上下文含糊不清的表達方式」?在SWIFT 3.0
let components = calendar.components([.day , .hour , .minute , .second] , fromDate: timeNow, toDate: timeEnd, options: [])
做到了,但同樣的錯誤仍然是有 – Bilal
@Bilal你有沒有跟我更換你的代碼,什麼是錯誤?你能顯示屏幕快照如果可能的話。請注意,此方法中沒有可選參數。 –
謝謝:)它的工作和錯誤刪除:) – Bilal