首页 > 解决方案 > 线程 1: EXC_BAD_ACCESS (code=1, address=0x48) - 被 iOS13.1 破坏了 (dev build 2)

问题描述

所以,我昨天将我的 iPhone 6S 更新到了 iOS13.1 的第二个开发版本,突然我的应用程序(在应用程序商店中,Connect 应用程序上显示 0 个崩溃)在我的设备上运行时无法运行。然而,它确实可以在 Xcode 的模拟器中工作。我使用的是 Xcode 10.3,但 Xcode 11 测试版做同样的事情,模拟器也可以在测试版上运行(尽管它们以其他方式破坏了我的应用程序)。

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

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

这段代码在哪

// 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)
        }

我不知道它为什么突然这样做,但因为我无法弄清楚我有点害怕,因为我确信 iOS 13 很快就会出来。

请帮忙!

标签: iphoneios13swift5

解决方案


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

var audioPlayer_GetReady = AVAudioPlayer()

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

var audioPlayer_GetReady: AVAudioPlayer

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

var audioPlayer_GetReady: AVAudioPlayer!

推荐阅读