【发布时间】:2017-06-14 14:33:25
【问题描述】:
帮助!我遇到错误'表达式类型'(_,_.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。 -
@rmaddy 即使将
offsetTime设置为 0.0 也会以某种方式起作用,但这个表达式仍然具有可读性模糊的上下文。也许一个更优雅的解决方案将是这个:let offsetTime : TimeInterval = 0