I have 3 labels inside my view, and this is how I get sensor data and write it inside labels:
func myDeviceMotion(){
print("Start DeviceMotion")
motion.deviceMotionUpdateInterval = 0.5
motion.startDeviceMotionUpdates(to: OperationQueue.current!) {
(data, error) in
print(data as Any)
if let trueData = data {
self.view.reloadInputViews()
self.xDevi!.text = "x (pitch): \(trueData.attitude.pitch)"
self.yDevi!.text = "y (roll): \(trueData.attitude.roll)"
self.zDevi!.text = "z (yaw): \(trueData.attitude.yaw)"
}
}
return
}
Now I would like to save that date inside a csv file. How can I do that?
I have already tried the solution proposed inside this answer: How to log sensor data and export to CSV?, but it doesn't work for me.