Hi. I have the following code with results in an error message
//
// ViewController.swift
// Accelerometer
//
//
import UIKit
import CoreMotion
let motion = CMMotionManager()
class ViewController: UIViewController {
@IBOutlet var xaxis: UILabel!
@IBOutlet var yaxis: UILabel!
@IBOutlet var zaxis: UILabel!
let movementManager = CMMotionManager()
override func viewDidLoad() {
super.viewDidLoad()
movementManager.startAccelerometerUpdates()
movementManager.accelerometerUpdateInterval = 0.1
Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { _ in
if let data = self.movementManager.accelerometerData {
// self.xaxis.text = String(data.acceleration.x)
//self.yaxis.text = String(data.acceleration.y)
//self.zaxis.text = String(data.acceleration.z)
var xoutput: () = self.xaxis.text = String(data.acceleration.x)
var xoutput = xoutput * 9.81
print(xoutput)
}
}
}
}
I realize that it is not working since the whole value of "xoutput" has a string in it. Any advice on making it so it will be a Double?
THANK YOU!
Topic:
Developer Tools & Services
SubTopic:
Xcode