Output is stuck on String

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!

First a question.

What do you mean with:

xoutput: () = self.xaxis.text =
String(data.acceleration.x)

Which type do you expect for xoutput ?

Secondly, you redeclare xoutput. that's an error.

                var xoutput = xoutput * 9.81

Why not simply:

var output = String(data.acceleration.x * 9.81)

An advice, seeing some of your posts. You should probably spend some time to learn Swift and app development from Apple's tutorials. For instance, Develop in Swift fundamentals (in Apple Library).