Challenge: Run Code on the Main Thread | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/10376245-networking-with-urlsession/lessons/4

Hi Brian,

Can you please elaborate on why the GCD code in UIKit needs the main queue to be specified to update the UI whereas in SwiftUI, that is not required?

Thanks

1 Like

Hi Brian,

Forgot to ask… In the challenge, we used GCD to perform an operation on a background thread, then we accessed the main thread to update the UI. Is there a way to do this using OperationQueue as well?

Thanks

I also have the same question: “why does the GCD code in UIKit needs the main queue to be specified to update the UI whereas in SwiftUI, that is not required?”

Every app comes with a Main queue, which is a serial queue that executes tasks on the main thread. This queue is responsible for drawing. It can be challenging or even overwhelming to prepare for a job interview or Every Cocoa application has a minimum of one thread , the main thread.

myaccountaccess login