Group Group Group Group Group Group Group Group Group

Challenge: Fetch Artwork over the Network | raywenderlich.com


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

You said we didn’t have to put the UI code to main thread in SwiftUI since musicItems was a State variable.
Do we really need DispatchQueue.main.async closure here?

     // https://www.raywenderlich.com/10376245-networking-with-urlsession/lessons/7
      //DispatchQueue.main.async {
        self.musicItems = response.results
      //}

I tried it worked well without DispatchQueue.main.async closure.

Yes, per that logic, we aren’t updating a user interface element. I’ll dig some more digging around, but I’m guessing you are right.