【问题标题】:Swift: runtime error crash only in release modeSwift:运行时错误仅在发布模式下崩溃
【发布时间】:2021-10-22 07:12:15
【问题描述】:

我在调试模式下没有得到这个,但是当我将运行模式切换到释放模式时,我的手机在以下行崩溃:

self.podcasts = PodcastsView(play: { audio in
        self.videoPlayerView.pause()
        self.showVideoPlayer = false
        self.audioPlayerView.play(audio: audio)
        self.audioCurrentlyPlaying = audio
        self.showAudioPlayer = true
        self.playBarShowing = true
    }, indentBottom: Binding(get: {
        self.playBarShowing
    }, set: {
        self.playBarShowing = $0
    }))

错误:Thread 1: EXC_BAD_ACCESS (code=1, address=0xfffffffffffffff0)

这是被调用的初始化器:

init(play: @escaping (_ audio: KHKAudio) -> Void, indentBottom: Binding<Bool>) {
    self.play = play
    self.model = PodcastsViewModel()
    self.indentBottom = indentBottom
}

【问题讨论】:

    标签: swift debugging swiftui runtime release


    【解决方案1】:

    我想通了。在被调用的初始化程序中,“模型”是@ObservedObject,而不是@StateObject。改变它修复了它。不过,我不明白为什么,以及为什么这只是一个发布问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-17
      • 2020-04-04
      • 2019-07-26
      • 1970-01-01
      相关资源
      最近更新 更多