Stéphane de Luca
Stéphane de Luca

Reputation: 13583

EXC_BAD_ACCESS while accessing CMDeviceMotion instance

I get a "Thread 1: EXC_BAD_ACCESS (code=1, address=0x50)" in a view controller code triggered by an observer:

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

Where deviceMotion is defined as follows:

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

While tracing step by step, the instance is created ok in the AppDelegate, then the error is triggered.

Additional information: This code is also used in another view controller, with no problem.

Upvotes: 1

Views: 43

Answers (0)

Related Questions