SwiftUI - publishing changes from background threads is not allowed
Andrew Fletcher published: 28 December 2020 (updated) 29 December 2020 3 minutes read
The purple warning notification of annoyance recently came my way! I received the following warning:
Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates.
What was happening?
The functionality of the code uses URLSession to get a user's name via API and the display is simple piece that initially message of Hello {user}.