I am trying to record the data from the iPhone\'s accelerometer (my own iPhone 5s) and set a label on the screen to that data using String(format: \"%.2f\", data)
w
NSHipster has a good article to talk about the core motion: http://nshipster.com/cmdevicemotion/
A better way to regularly update UI with motion data is to use the patter as shown in below:
if manager.accelerometerAvailable {
manager.accelerometerUpdateInterval = 0.1
manager.startAccelerometerUpdatesToQueue(NSOperationQueue.mainQueue()) {
[weak self] (data: CMAccelerometerData!, error: NSError!) in
accelX.text = String(format: "%.2f", data.acceleration.x)
}
}