编辑代码

 @objc func buttonCheckMusicTimer(_ sender : UIButton) {
    if GameOver {return}
    let tipsLabel = self.view.viewWithTag(1001) as! UILabelvar tag = sender.tag
    if tag >= 5000 {
        tag -=5000
    }
    else if tsg >= 4000 {
        tag -=4000
    }
    let row = Int (tag / cols)
    let col - tag  - cols * row
    let result = errorCords.filter {
        $0 == (row,col)
    }
    let reserved = errorCords.filter {
        $0 != (row,col)
    }
    errorCords = reserved

    if result.count >= 1 {
        sender.backgroundColor = .reservedlet path = Bundle.main.path(forResource: "birdsound", ofType: "m4a")
        let ur1 = URL(fileURLWithPath:path!)
        soundPlayer=try? AVAudioPlayer(contentsOf: ur1)
        soundPlayer.play()
        tipsLabel.text = "不同找到:(\(row),\(col)),还剩\(errorCords.count)个"
        if errorCords.count <= 0 {
            GameOver = true
            tipsLabel.text = "任务完成,共花费时间\(self.TimeCost) 秒"
        }
    }
  else{
      sender.backgroundColor = .brown
      let path = Bundle.main.path|(forResource:"error",ofType:"m4a")
      let url = URL (fileURLWithPath: path!)
      soundPlayer.play()
      tipsLabel.text = "找错了: (\(row),\(col))"
      }
}