<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreMotion",
  "identifier" : "/documentation/CoreMotion/CMMagnetometerData",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Motion"
    ],
    "preciseIdentifier" : "c:objc(cs)CMMagnetometerData"
  },
  "title" : "CMMagnetometerData"
}
-->

# CMMagnetometerData

Measurements of the Earth’s magnetic field relative to the device.

```
class CMMagnetometerData
```

## Overview

Your application can obtain samples of magnetometer measurements, as represented by instances of this class, from the block handler of the [`startMagnetometerUpdates(to:withHandler:)`](/documentation/CoreMotion/CMMotionManager/startMagnetometerUpdates(to:withHandler:)) method or from the [`magnetometerData`](/documentation/CoreMotion/CMMotionManager/magnetometerData) property of the `CMMotionManager` class.

> Note:
> The ``doc://com.apple.coremotion/documentation/CoreMotion/CMMotionManager/magnetometerData`` property of `CMMotionManager` provides a non-`nil` value only if you have called the `startMagnetometerUpdates()` method or the ``doc://com.apple.coremotion/documentation/CoreMotion/CMMotionManager/startMagnetometerUpdates(to:withHandler:)`` method to start magnetometer updates.

## Topics

### Getting the Field Strength

[`magneticField`](/documentation/CoreMotion/CMMagnetometerData/magneticField)

Returns the magnetic field measured by the magnetometer.

[`CMMagneticField`](/documentation/CoreMotion/CMMagneticField)

A structure containing 3-axis magnetometer data

## Relationships

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`Equatable`](/documentation/Swift/Equatable)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Hashable`](/documentation/Swift/Hashable)

### Inherits From

[`CMLogItem`](/documentation/CoreMotion/CMLogItem)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)