Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

swift try catch

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)")
}
Source by codewithchris.com #
 
PREVIOUS NEXT
Tagged: #swift #catch
ADD COMMENT
Topic
Name
7+7 =