func differenceCreate(mount:Int) {
for _ in 0..<mount {
let col = Int(arc4random()) % cols
let row = Int(arc4random()) % rows
errorCords.append((row,col))
let index = Int(arc4random()) % images.count
let which = Int(arc4random()) % 2
if which == 0 {
iv1[cols*row + col] = images[index]
}
else {
iv2[cols*row + col] = images[index]
}
}
}
@objc func buttonCheckMusic(_sender : UIButton) {
let tipsLabel = self.view.viewWithTag(1001) as! UiILabel
var tag = sender.tag
if tag >= 5000 {
tag -= 5000
}
else if tag >= 4000 {
tag -= 4000
}
let row = Int (tag / cols)
let col = tag - cols * row
let result = errorCords.filter {
$0 == (row,col)
}
if result.count >= 1 {
let path = Bundle.main.path(forResource:"birdsound",ofType:"m4a")
let url = URL(fileURLWithPath: path!)
soundPlayer=try? AVAudioPlayer(contentsOf: url)
soundPlayer.play()
tipsLabel.text = "找错啦: (\(row),\(col))"
}
}