Gyroscope
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 {
motionManager.accelerometerUpdateInterval = 0.25
motionManager.startAccelerometerUpdates(to: motionQueue, withHandler: onAccelerometerUpdate)
}
if motionManager.isGyroAvailable {
motionManager.gyroUpdateInterval = 0.25
motionManager...