幫助!我遇到錯誤「表達式類型」(_,_.Stride) - > _'在沒有更多上下文的情況下不明確「。有誰知道爲什麼會發生這種情況,並有解決方案嗎?我使用雨燕4
代碼:表達式類型'(_,_.Stride) - > _'在沒有更多上下文的情況下不明確
let offsetTime = 0
DispatchQueue.main.asyncAfter(deadline: .now() + offsetTime) { //Expression type '(_, _.Stride) -> _' is ambiguous without more context
self.currentTaskForUser.text = "Starting\n" + note + "in"
self.timerDown(from: 3, to: 1)
}
DispatchQueue.main.asyncAfter(deadline: .now() + offsetTime + 3) { //Expression type '(_, _.Stride) -> _' is ambiguous without more context
self.currentTaskForUser.text = note
let difficultyValue = Int(self.difficultyControl.titleForSegment(at: self.difficultyLevel.selectedSegmentIndex)!)!
self.timerUp(from: 1, to: difficultyValue)
self.offsetTime += 13
}
嘗試將'let offsetTime = 0'更改爲'let offsetTime = 0.0'。 – rmaddy
@rmaddy即使將'offsetTime'設置爲0.0,也會以某種方式工作,但該表達式仍具有可讀性不明確的上下文。也許更優雅的解決方案是這樣的:'讓offsetTime:TimeInterval = 0' –