Start accelerometer.
- (void)startAccelerometerData {
motionManager = [[CMMotionManager alloc] init];
motionManager.accelerometerUpdateInterval = 1/60.0;
[motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue currentQueue]
withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {
NSLog(@"x:= %f y:= %f z:= %f", accelerometerData.acceleration.x, accelerometerData.acceleration.y, accelerometerData.acceleration.z);
} ];
}
stop accelerometer
- (void)viewDidUnload {
[motionManager stopAccelerometerUpdates];
motionManager = nil;
[super viewDidUnload];
}