线程1:EXC_BAD_ACCESS(代码= 1,地址= 0x48)-与iOS13.1(开发版本2)一起损坏

jam*_*n34 5 iphone swift5 ios13

因此,昨天我将iPhone 6S更新为iOS13.1的第​​二个开发版本,突然间我的应用程序(在应用程序商店中显示为0崩溃显示在Connect应用程序上)在我的设备上运行时不起作用。但是,它确实可以在Xcode的模拟器中使用。我使用的是Xcode 10.3,但Xcode 11 Beta的功能相同,模拟器也可以在Beta上运行(尽管它们以其他方式破坏了我的应用程序)。

当我点击一个按钮时,应该使我进入所点击按钮的详细视图,但我收到此错误:

Thread 1: EXC_BAD_ACCESS (code=1, address=0x48)
Run Code Online (Sandbox Code Playgroud)

这段代码在哪

// 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)
        }
Run Code Online (Sandbox Code Playgroud)

我不知道为什么突然这么做,但是因为我不知道为什么,我有点害怕,因为我确定iOS 13很快就会问世。

请帮忙!

use*_*137 5

如果您在声明中启动了“ audioPlayer_GetReady”,则如下所示:

var audioPlayer_GetReady = AVAudioPlayer()
Run Code Online (Sandbox Code Playgroud)

尝试重组以仅声明其类型:

var audioPlayer_GetReady: AVAudioPlayer
Run Code Online (Sandbox Code Playgroud)

现在,您需要使用类的init-method对其进行初始化,或者,如果您确定在对其进行任何引用之前会在其他地方对其进行初始化,请使用惊叹号对其进行声明:

var audioPlayer_GetReady: AVAudioPlayer!
Run Code Online (Sandbox Code Playgroud)