Q:

UIButton not updating when called after web request

I have the following function enableEndButton() called after a web request is complete.
func enableEndButton() {
    print("Start")
    buttonState = true
    go_button.setBackgroundImage(UIImage(named: "stop.png"), for: .normal)
    go_button.setTitle("Stop", for: .normal)
    print("Done")
}

The two prints are output but the button doesn't change until I tap it. How can I get this happening instantly? 
This function is being called from within a dataTask as per:
let task = URLSession.shared.dataTask(with: url){
            data,response,error in
            if error != nil {
                print(error!)
            } else {
                weather_condition = self.parseWeatherJSON(weatherJSON: data!)
                //do something with weather_condition
                self.enableEndButton()

A:

Try wrapping your call to enableEndButton in your URLSession completion in a Dispatch
DispatchQueue.main.async {
    self.enableEndButton()
}

Edit:
For clarity since URLSessions runs on a background thread and UI Updates must be done on the main thread you need to dispatch it explicitly to the main thread, however log statements are not required to be run on the main thread.

