📜  swift do catch - Swift 代码示例

📅  最后修改于: 2022-03-11 15:00:58.809000             🧑  作者: Mango

代码示例2
do {
    // Create audio player object
    audioPlayer = try AVAudioPlayer(contentsOf: soundURL)
            
    // Play the sound
    audioPlayer?.play()
}
catch {
    // Couldn't create audio player object, log the error
    print("Couldn't create the audio player for file \(soundFilename)")
}