I think your motionManager
gets autoreleased. Add a instance variable or property to keep the motion manager anyway.
Also check if magnetometerAvailable
returns YES, otherwise it could be possible that your device does not support the magnetometer.