November 2016
Beginner
480 pages
11h 10m
English
The accelerometer is similar to the gyroscope. While the accelerometer detects translation along the x, y, and z axes, the gyroscope detects rotation around those axes:

Figure 11.2: Rotational motion along the x, y, and z axes
Using the gyroscope is very similar to using the accelerometer; we still need to set up our motionManager with an operation queue and a handler to process the data. Let's take a look at what the code looks like:
class ViewController: UIViewController { let motionManager = CMMotionManager() let motionQueue = OperationQueue() override func viewDidLoad() { super.viewDidLoad() if motionManager.isAccelerometerAvailable { ...Read now
Unlock full access