dimanche 21 septembre 2014

Weird console output swift


Vote count:

0




I'm not sure if this is a bug or if I'm doing something wrong but I'm seeing some weird text in the console when trying to print accelerometer values.


import SpriteKit import CoreMotion



class GameScene: SKScene {
let motionManager: CMMotionManager = CMMotionManager()
override func didMoveToView(view: SKView) {
/* Setup your scene here */
if (self.motionManager.accelerometerAvailable) {
self.motionManager.startAccelerometerUpdatesToQueue(NSOperationQueue()) {
(data, error) in
let xAndYCoords = "X: \(data.acceleration.x) and Y: \(data.acceleration.y)"
println(xAndYCoords)
}
}

}
}


Output(I'm adding an extra space between each line for readability):


X:X :0 .06.8657751347929167807297638483 8a nadn dY :Y 0.006027221679687:5 0.0081939697265625


X: 0.689010620117188X and Y: :0 .00.0658457271910152816470632453 7a5n d Y: 0.0070343017578125


X: 0.X: 0.667802327290643588697841387755 aanndd YY:: 00..00009066070565367624007602351 25


X: 0.6X6:8 803.86678530104927068596824 3a8nX :Xd a:0 n. Y6d06: 4. 6Y610:16.8 41006314.90006801271500 98a83n10d38 05Y47:98 83011.74205415 75 5a33n213d428 56Y3 2:8125 0.016815185546875


X: 0.668319702148438 and Y: 0.01080322265625


X: 0.669036865234375 and Y: 0.011260986328125


Initially I thought it was a precision thing even though you can see the and is getting messed up but I'm still seeing odd results.


import SpriteKit import CoreMotion



class GameScene: SKScene {
let motionManager: CMMotionManager = CMMotionManager()
override func didMoveToView(view: SKView) {
/* Setup your scene here */
if (self.motionManager.accelerometerAvailable) {
self.motionManager.startAccelerometerUpdatesToQueue(NSOperationQueue()) {
(data, error) in
println(NSString(format:"X: %.2f Y:%.2f", self.motionManager.accelerometerData.acceleration.x, self.motionManager.accelerometerData.acceleration.y))
}
}

}
}


Output: (again the spacing) X: 0.30 Y:-0.14


X: 0.30 Y:-0X.:1 40 .30 Y:-0.14


X: 0X.:2 90 .Y2:9- 0Y.:1-40 .14


X:X :0 .02.92 9Y:-0. 1Y4: -0.14


XX:: 00..2288 YY::--00..1144


X: 0.28 Y:-0.14


X: 0.28 Y:-0.14


X: 0.27 Y:-0.14


X: 0.27 Y:-0.14


X: 0.X2:8 0Y.:2-80.15 Y:-0.15


X: 0.27 Y:-X0:. 105. 27 Y:-0.15


XX:: 00..2277 YY::--00..1144


X: 0.28 Y:-0.15


X: 0.28 Y:-0.15


X: 0.29 Y:-0.15


X: 0.29 Y:-0.15


X: 0.29 Y:-0.15


X: 0.29 Y:-0.15



asked 26 secs ago







Weird console output swift

Aucun commentaire:

Enregistrer un commentaire