I'm beginning coding with the DeviceMotion class. After following Apple's documenation, i have the following:
- (void)viewDidLoad {
[super viewDidLoad];
myMM = [[CMMotionManager alloc] init];
myMM.deviceMotionUpdateInterval = 1.0/30.0;
theQ = [[NSOperationQueue currentQueue] retain];
motionHandler = ^ (CMDeviceMotion *motionData, NSError *error) {
if (motionData.rotationRate.z > 5.5 || motionData.rotationRate.z < -5.5) {
NSLog(@"Rotation of Z."); // Reference A
}
};
-(IBAction)toggleClick{
NSLog(@"toggle");
if(myMM.gyroAvailable){
if(myMM.deviceMotionActive){
NSLog(@"Stopping Motion Updates..");
[myMM stopDeviceMotionUpdates];
} else {
NSLog(@"Starting Motion Updates..");
[myMM startDeviceMotionUpdatesToQueue:theQ withHandler:motionHandler];
}
}
else {
NSLog(@"No motion available. Quit!");
}
This code works fine, however when I want to do any code except an NSLog (even something as simple as incrementing an integer) in place of the 'reference A', I get an EXEC Bad Access in the console.
I've looked around, and all I've found is that it's a memory leak of sorts. Does anyone know whats going on? If not, how can I figure it out? I'm pretty inexperienced with Instruments, but if I'm pointed in the right direction I'd be much appreciated.