Collecting Motion Data

Apps register for data from the acceleration sensors through an instance of CMMotionManger defined in the framework CoreMotion. Open ViewController.swift and import CoreMotion right below the existing import statement. Then import the LogStore logging library:

 import​ ​UIKit
 import​ ​CoreMotion
 import​ ​LogStore

We need a property for the CMMotionManager instance. Add the highlighted property declaration in the following code at the beginning of ViewController:

 class​ ​ViewController​: ​UIViewController​ {
»let​ motionManager = ​CMMotionManager​()
 override​ ​func​ ​viewDidLoad​() {
 super ...

Get Build Location-Based Projects for iOS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.