在从Swift 2转换为Swift 3之后,我使用了这段代码,然后出现了这个错误消息。任何帮助都将不胜感激。我对斯威夫特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()
}
}
最佳答案
这里有:
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