I have an async api call and I'm using the delegate pattern and assigned a protocol methods to handle what to do with the data when we receive the response from api
didWeatherUpdate
I implement this in a delegate. The way I understand it, This method which I use to update the UI with data from api won't fire until the async network request is done.
My question is why does the main thread is need to be explicitly told that it is an async process. if the function will not be called until the data is ready after api call is complete. My assumption is that when the data is ready the function fires then added to queue that main thread works through. It seems so extra coming from a full stack background
func didWeatherUpdate(_ weatherManager: WeatherManager,_ weather: WeatherModel){
print("\(weather.temperature) from the controller")
DispatchQueue.main.async{
self.temperatureLabel.text = weather.temperatureString
}