我在从Swift 2转换为Swift 3后立即使用了这段代码,并出现了此错误消息。任何帮助将不胜感激。我是Swift 3的新手。
func checkIfCorrect (_ buttonPressed:Int) {
if buttonPressed == playlist[numberOfTaps] {
if numberOfTaps == playlist.count - 1 { // we have arrived at the last item of the playlist
let time = DispatchTime(uptimeNanoseconds: DispatchTime.now()) + Double(Int64(NSEC_PER_SEC)) / Double(NSEC_PER_SEC)
DispatchQueue.main.asyncAfter(deadline: time, execute: {
self.nextRound()
})
return
}
numberOfTaps += 1
}else{ // GAME OVER
resetGame()
}
}
答案 0 :(得分:3)
你有这个:
let time = DispatchTime(uptimeNanoseconds: DispatchTime.now()) + Double(Int64(NSEC_PER_SEC)) / Double(NSEC_PER_SEC)
把这个:
let time = DispatchTime.now() + 1.0 // or however long you want the delay to be