2014-01-20 54 views
1

我已經閱讀了大量的文章,並通過開發手冊,無法準確找到如何設置CMCalibratedMagneticField,以便獲取數據。爲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. 

我知道這可能是一個愚蠢的問題,因爲有文件,但我只是不理解設置的語法。任何幫助將非常感激。

回答

0

所以設置它的正確方法是:

CMCalibratedMagneticField magfield = motion.magneticField; 
//send in the magfield to the function. 

在我的代碼,我間接地試圖引用這個代碼的函數方面的價值,因此無法從中得到任何直接的價值。但我的函數調用現在看起來像:

-(void)showMagneticfield:(CMCalibratedMagneticField)magfield 

,然後調用做magfield.field的各個領域(軸)