ios - Swift / MotionKit.framework / how to update label -


i'm trying exploit motion data. i've created test app using motionkit framework. print(teststring) prints x variables correctly console in 1 second interval. testlabel not updated once.

import uikit import motionkit  class viewcontroller: uiviewcontroller {  @iboutlet weak var testlabel: uilabel!  let motionkit = motionkit()  override func viewdidload() {     super.viewdidload()      motionkit.getaccelerometervalues(1.0) { (x, y, z) -> () in         let teststring = string(x)         self.testlabel.text = teststring         print(teststring)                 } }  override func didreceivememorywarning() {     super.didreceivememorywarning() } } 

what missing? appreciated.

just wrap textfield text code in dispatch_async

dispatch_async(dispatch_get_main_queue(), ^{        self.testlabel.text = teststring       }); 

Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -