我需要从块外部访问块内部生成的值。看来唯一的方法是在完成时输出,否则输出将在执行该块之前显示。什么是正确的语法来检测此类块的完成?
__block CGFloat Angle;
[self.motionManager startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXArbitraryZVertical
toQueue:[NSOperationQueue currentQueue]
withHandler:^(CMDeviceMotion *motion, NSError *error)
{
[[NSOperationQueue mainQueue] addOperationWithBlock:
^{
CGFloat angle;
NSLog(@"angle = %f",angle);
Angle = angle;
}
];
/* This gives me error
[[NSOperationQueue mainQueue] setCompletionBlock:^
{
NSLog(@"Angle = %f",Angle);
}];
*/
}
];