1

I want get data from url, but until process complete, i want show loading icon

I use this code but not work for me

DispatchQueue.global(qos: .background).async {
    // show loading icon
    // start get data
    DispatchQueue.main.async {
        // remove loading icon
    }
}
Abar New
  • 27
  • 2
  • 8

1 Answers1

0

From UIView

Threading Considerations

Manipulations to your application’s user interface must occur on the main thread. Thus, you should always call the methods of the UIView class from code running in the main thread of your application. The only time this may not be strictly necessary is when creating the view object itself but all other manipulations should occur on the main thread.

Which means you should probably show/hide and manipulate therefore your View in the Main thread and not in a background thread as you are doing in "show loading view".

Community
  • 1
  • 1
enwonder
  • 49
  • 1
  • 5