0

I used this piece of code right after converting from Swift 2 to Swift 3, and this error message came up. Any help would be greatly appreciated. I am very new to 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()
    }
}
rmaddy
  • 298,130
  • 40
  • 468
  • 517

1 Answers1

3

Where you have this:

let time = DispatchTime(uptimeNanoseconds: DispatchTime.now()) + Double(Int64(NSEC_PER_SEC)) / Double(NSEC_PER_SEC)

put this:

let time = DispatchTime.now() + 1.0 // or however long you want the delay to be
matt
  • 447,615
  • 74
  • 748
  • 977