func playSound() {
let soundUrl = Bundle.main.url(forResource: "note1", withExtension: "mp3")
do {
try toneplayer = AVAudioPlayer(contentsOf: soundUrl!)
} catch {
print("the error code",error)
}
}
@IBAction
func anypressed(_ sender: UIButton) {
playSound()
}
我尝试捕获该错误,但未在Xcode 11.4.1上打印。当我将扩展名更改为wav的mp3时,应该会出现错误。