Swift异常 try 使用方式
@H_502_3@try方式do{
let backgroundMusicPlayer = try AVAudioPlayer(contentsOf: url)
// .....
}catch{
print(error)
}
try?方式
guard let backgroundMusicPlayer = try? AVAudioPlayer(contentsOf: url) else {
return
}
try!方式
let backgroundMusicPlayer = try! AVAudioPlayer(contentsOf: url)
try!方式 一旦有异常,程序直接奔溃