I have the following code:
var gaugeView1 = CHCircleGaugeView(frame: CGRectMake(0, 0, 280, 280))
self.mainGaugeView.addSubview(gaugeView1)
gaugeView1.setTitleValue("TODAY", hideLabel: false);
var query = PFQuery(className: "Values")
query.findObjectsInBackgroundWithBlock({ (objects, error) in
if let valObjects = objects as? [PFObject] {
for val in valObjects {
if let average = val.objectForKey("AVERAGE") as? Double {
dispatch_sync(dispatch_get_main_queue(), { () -> Void in
gaugeView1.setValue(average, hideLabel: false, animated: true)
})
}
}
}
})
The problem is that the gaugeView1.setValue()
is not actually updating the value.
Originally I didn't have it running on the main thread and then added in the dispatch_sync()
unfortunately that hasn't fixed the problem.
You should use dispatch_async
instead of dispatch_sync
:
dispatch_async(dispatch_get_main_queue(), { () -> Void in
gaugeView1.setValue(average, hideLabel: false, animated: true)
})