无法将值类型“”转换为预期参数“UInt64'

问题描述:

从Swift 2转换到Swift 3后,我使用了这段代码,并且出现了此错误消息。任何帮助将不胜感激。我是很新的雨燕3.无法将值类型“”转换为预期参数“UInt64'

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

什么是完整的错误?哪条线路导致错误? – rmaddy

如果你有这样的:

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 
+0

更简单,使用我的'延迟'功能:http://*.com/a/24318861/341994 – matt