I have the following code, I always get a breakpoint on "try btnSound". Not sure where I'm doing wrong. The Sound file is in main folder.
import UIKit
import AVFoundation
class ViewController: UIViewController {
@IBOutlet weak var outputLbl: UILabel!
var btnSound: AVAudioPlayer = AVAudioPlayer()
override func viewDidLoad() {
super.viewDidLoad()
let path = Bundle.main.path(forResource: "btn", ofType: "wav")
do {
try btnSound = AVAudioPlayer(contentsOf: URL(fileURLWithPath: path!))
btnSound.prepareToPlay()
} catch let err as NSError {
print(err.debugDescription)
}
}
@IBAction func numberPressed(btn: UIButton!){
btnSound.play()
}
}