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
  • 314,917
  • 42
  • 532
  • 579
user6794475
  • 23
  • 1
  • 5

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
  • 515,959
  • 87
  • 875
  • 1,141