Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Thread 1: EXC_BAD_ACCESS (code=1, address=0x48) - broken with iOS13.1 (dev build 2)

So, I updated my iPhone 6S to the second dev build of iOS13.1 yesterday and all of the sudden my app (which is on the app store with 0 crashes showing on the Connect app) doesn't work when run on my device. It does however work in Xcode's simulators. I'm using Xcode 10.3, but the Xcode 11 beta does the same thing, the simulators work on the beta too (though they break my app in other ways).

When I tap on a button, which is supposed to bring me to the detail view of the button tapped I'm getting this error:

Thread 1: EXC_BAD_ACCESS (code=1, address=0x48)

Which is on this code

// sets up the audio for use in the app --------------------------------------------------------------//
        let GetReady = Bundle.main.path(forResource: “Get_Ready_up9db”, ofType: “m4a”)
        // this tells the compiler what to do when action is received
        do {
            audioPlayer_GetReady = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: GetReady! )) // Thread 1: EXC_BAD_ACCESS (code=1, address=0x48)
            try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category(rawValue: convertFromAVAudioSessionCategory(AVAudioSession.Category.ambient)))
            try AVAudioSession.sharedInstance().setActive(true)
        }
        catch{
            print(error)
        }

I have no idea why it's doing this all of the sudden, but because I can't figure it out I'm a bit scared as I'm sure iOS 13 is coming out very, very soon.

Please help!

like image 755
jammyman34 Avatar asked Sep 05 '19 21:09

jammyman34


1 Answers

If you have initiated your "audioPlayer_GetReady" in it's declaration like this:

var audioPlayer_GetReady = AVAudioPlayer()

Try to restructure to only declare it's type:

var audioPlayer_GetReady: AVAudioPlayer

You now need to initialize it in the init-method of your class or, if you are sure that it will be initialize elsewhere before any reference to it, declare it with exclamation:

var audioPlayer_GetReady: AVAudioPlayer!
like image 173
user1755137 Avatar answered Oct 05 '22 01:10

user1755137