帮帮我!我遇到了错误:“表达式类型 '(_, _.Stride) -> _' 在没有更多上下文的情况下是不明确的”。有谁知道为什么会出现这种情况,并且有解决方法吗?我正在使用Swift 4。
代码:
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
。 - rmaddyoffsetTime
设置为 0.0,这个表达式仍然存在可读性模糊的上下文。也许更优雅的解决方案是:let offsetTime: TimeInterval = 0
。 - Zell B.