gpt4 book ai didi

swift - 无法将值类型 ""转换为预期参数 'UInt64'

转载 作者:行者123 更新时间:2023-11-28 11:00:16 32 4
gpt4 key购买 nike

我在从 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()
}
}

最佳答案

哪里有这个:

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

关于swift - 无法将值类型 ""转换为预期参数 'UInt64',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40955083/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com