Question : swift try catch
Answered by : happy-hyena-j4t6squdpbx2
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 : https://codewithchris.com/swift-try-catch/ | Last Update : Fri, 18 Jun 21
Question : Swift Handling Errors Using do-catch Statement
Answered by : samer-saeid
do { try division(numerator: 10, denominator: 0) ...
}
catch DivisionError.dividedByZero { // statement
}
Source : | Last Update : Thu, 23 Jun 22
Question : Swift Error Handling
Answered by : samer-saeid
var numerator = 10
var denominator = 0
// try to divide a number by 0
var result = numerator / denominator // error code
Source : | Last Update : Thu, 23 Jun 22