Sensors on Apple Watch
Now, while we've exhausted most of our sensory options on iOS, there's still plenty of room to explore on watchOS! In this section, we'll combine what we've learned about sensors in this chapter with the watchOS development we learned in the last chapter. The end goal is to get information from the Apple Watch's accelerometer, and then bring it back to iOS and display it on a chart. Let's do it!
Once again, before we start let's clear out our ViewController
class to get rid of the altimeter processing that we were playing with in the last section. Your ViewController.swift
file should look like this as we begin our Apple Watch experiment:
import UIKit import CoreMotion import Charts class ViewController: UIViewController { @IBOutlet weak var lineChartView: LineChartView! var dataSet = LineChartDataSet(values: [], label: "Values") override func viewDidLoad() { super.viewDidLoad() } ...