为什么无法快速打印错误代码

时间:2020-05-27 14:04:09

标签: swift

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时,应该会出现错误。

0 个答案:

没有答案