Skip to content

Commit bef606a

Browse files
committed
Placed UI update code inside dispatchqueue as the UI code needs to be updated in the main thread.
1 parent aeee11c commit bef606a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

iOS/IoT-Sample/Swift/IoTSampleSwift/PublishViewController.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ class PublishViewController: UIViewController, CLLocationManagerDelegate {
6262

6363
if msgState == "UPDATE_STATUS" {
6464
let garageState = reportedState["DATA"] as! String
65-
self.statusLabel.text = garageState
65+
DispatchQueue.main.sync {
66+
// Update the statusLabel with the garage state
67+
self.statusLabel.text = garageState
68+
}
6669
}
6770
} else {
6871
print("bad json")

0 commit comments

Comments
 (0)