I got a small problem, let me start with the code
class ViewController: UIViewController {
@IBOutlet weak var LBoutput: UILabel!
@IBAction func BTclick(sen
In Swift 3:
DispatchQueue.main.async
{
self.LBoutput.text = "test6"
}
Usual problem of updating UI in a secondary thread:
Your closure is obviously not running on the main thread, as the URL task is asynchronous. So updating the label on the closure will have to wait for the main thread to run its update loop. The way to fix it is to wrap the .text =
call to force it to run on the main thread (which is where the UI stuff should run anyway):
dispatch_async(dispatch_get_main_queue()) {
self.LBoutput.text = "test6"
}