1

我在观察者触发的视图控制器代码中得到“线程 1:EXC_BAD_ACCESS (code=1, address=0x50)”:

guard let app = UIApplication.shared.delegate as? ExtendedAppDelegated else { return }
let deviceAngle = app.deviceMotion.attitude.yaw // EXC_BAD_ACCESS

其中 deviceMotion 定义如下:

class AppDelegate {
    open var deviceMotion = CMDeviceMotion() // Not an optional
}

一步一步跟踪,在AppDelegate中创建好实例,然后触发错误。

附加信息:此代码也在另一个视图控制器中使用,没有问题。

4

0 回答 0