Re-Assigning instance of AVAudioPlayer in iOS13 leads to BAD_ACCESS runtime error

后端 未结 2 880
耶瑟儿~
耶瑟儿~ 2020-12-10 16:44

I have an app, that is for many years in the AppStore and runs without any crashes (last deployment target iOS 12.4). I have some code for playing a sound on certain events

相关标签:
2条回答
  • 2020-12-10 16:50

    private var mySoundPlayer: AVAudioPlayer = AVAudioPlayer()

    AVAudioPlayer doesn't have init() listed as a valid initializer. The reference page shows four separate initializers, all of which take at least one parameter. If you were using the line above in code prior to iOS 13.1 without crashing, you were initializing the audio player incorrectly and probably just getting lucky that it wasn't a problem.

    I don't know what changed specifically with AVAudioPlayer in iOS 13.1, but the release notes show quite a few audio-related changes, and it seems likely that some change to that class introduced a dependency on something that happens at initialization time.

    0 讨论(0)
  • 2020-12-10 17:07

    Just remove the initialisation and it will work

    private var mySoundPlayer: AVAudioPlayer!

    Cheers!!!

    0 讨论(0)
提交回复
热议问题