Is DispatchQueue.global(qos: .userInteractive).async same as DispatchQueue.main.async

The “quality of service” definitions are described here:

https://developer.apple.com/library/content/documentation/Performance/Conceptual/EnergyGuide-iOS/PrioritizeWorkWithQoS.html

It looks like the “main” thread will have a QoS class of “User-interactive”. However, just because a thread is created with a QoS of “User-interactive”, does not mean that it is the “main” thread.

You can observe this in the Xcode debugger. Put a breakpoint inside the async block and look at the Debug Navigator active thread panel. When DispatchQueue.global(qos: .userInteractive).async{} is called from the main thread, it displays with a different name than the main thread.

In general, the main thread is considered the special thread where all view-related access should be performed. If something will consume any significant time, e.g. calling a web service, compressing a file, etc., you will want to run code in a separate queue, and when the process completes, return to the main queue where you update the user interface.

Note also that when using Xcode 9 with iOS 11, a warning will be emitted when a user-interface object is accessed from a non-main thread.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)