I am trying to initialize the device motion controller in a class that contains all of my global variables for use in different classes. However, I cannot get this work to work.
I have this in my global class:
CMMotionManager *motionManager;
Then set the property in the header file of another class:
@property (retain) CMMotionManager *motionManager;
And in the .m file I synthetize and run the updates:
@synthesize motionManager;
motionManager = [[CMMotionManager alloc] init];
if (motionManager.deviceMotionAvailable)
{
motionManager.deviceMotionUpdateInterval = 1.0/100.0;
[motionManager startDeviceMotionUpdates];
NSLog(@"Device Started");
}
But when I call it in my third grade:
motionManager.deviceMotionAvailable
It returns NO.
PD: both classes import the global class, and the third class imports the second header.
source
share