iOS Developer Library — Prerelease

Developer

Core Motion Framework Reference CMMagnetometerData Class Reference

Options
Deployment Target:

On This Page
Language:

CMMagnetometerData

Instances of the CMMagnetometerData class encapsulated measurements of the magnetic field made by the device’s magnetometer.

Your application can obtain samples of magnetometer measurements, as represented by instances of this class, from the block handler of the startMagnetometerUpdatesToQueue:withHandler: method or from the magnetometerData property of the CMMotionManager class.

  • Returns the magnetic field measured by the magnetometer. (read-only)

    Declaration

    Swift

    var magneticField: CMMagneticField { get }

    Objective-C

    @property(readonly, nonatomic) CMMagneticField magneticField

    Discussion

    The value of this property is the total magnetic field observed by the device which is equal to the Earth’s geomagnetic field plus bias introduced from the device itself and its surroundings.

    This is the “raw” magnetic-field value, unlike the calibrated value of the magneticField property of CMDeviceMotion which filters out the bias introduced by the device and, in some cases, its surrounding fields.

    Availability

    Available in iOS 5.0 and later.