Hi,
I just installed an Xcode update and now my game app freezes when I build it and has a debug error statement:
Thread 1: EXC_BAD_ACCESS(code=1, address=0x48)
on the AVAudioPlayer line:
do {backgroundAudio = try AVAudioPlayer(contentsOf: audioNSURL as URL) }
Here is the complete code in GameViewController that used to work fine:
Import SpriteKit
Import GameplayKit
Import AVFoundation
class GameViewController: UIViewController {
var backgroundAudio = AVAudioPlayer()
override func viewDidLoad() {
super.viewDidLoad()
let filePath = Bundle.main.path(forResource: “MySong”, ofType: “wav”)
let audioNSURL = NSURL(fileURLWithPath: filePath!)
do {backgroundAudio = try AVAudioPlayer(contentsOf: audioNSURL as URL) }
catch {return print(“Cannot Find The Audio”)}
backgroundAudio.numberOfLoops = -1
backgroundAudio.volume = 0.7
background.play()
}
What has happened and how can I fix this?