Ios 为CMCalibredMagneticField设置

Ios 为CMCalibredMagneticField设置,ios,xcode,sensors,core-motion,magnetometer,Ios,Xcode,Sensors,Core Motion,Magnetometer,我已经阅读了很多帖子和开发手册,但找不到确切的方法来设置CMCalibratedMagneticField,以便获取数据 我正在使用: [motionManager startDeviceMotionUpdatesUsingReferenceFrame: CMAttitudeReferenceFrameXMagneticNorthZVertical toQueue: [NSOperationQueue currentQueue] withHandler:^(CMDeviceMotion *mot

我已经阅读了很多帖子和开发手册,但找不到确切的方法来设置CMCalibratedMagneticField,以便获取数据

我正在使用:

[motionManager startDeviceMotionUpdatesUsingReferenceFrame: CMAttitudeReferenceFrameXMagneticNorthZVertical toQueue: [NSOperationQueue currentQueue] withHandler:^(CMDeviceMotion *motion, NSError *error){
    //This is where I don't know how to get the calibrated data but I am trying:
    CMCalibratedMagneticField *magfield = motion.magneticField.field;
    //then sending it to a function where I pull the x, y, and z values.  

我知道这可能是一个愚蠢的问题,因为有文档,但我只是不理解设置的语法。任何帮助都将不胜感激

所以正确的设置方法是:

CMCalibratedMagneticField magfield = motion.magneticField;
//send in the magfield to the function.
在我的代码中,我间接地尝试引用此代码的函数端的值,因此无法从中获得任何直接值。但我的函数调用现在看起来像:

-(void)showMagneticfield:(CMCalibratedMagneticField)magfield
然后通过magfield.field.(axis)调用各个字段