Just a note, Data(contentsOf: URL) is synchronous, if you run this on the main thread and the image takes a while to load, the User Interface on the app will be not responsive to the user, you should wrap it with DispatchQueue.global().async { ... }.
And also avoid using DispatchQueue.main.sync on main thread (by default your code is already running on main thread), as it is synchronous and might result in deadlock!
Just a note, Data(contentsOf: URL) is synchronous, if you run this on the main thread and the image takes a while to load, the User Interface on the app will be not responsive to the user, you should wrap it with DispatchQueue.global().async { ... }.
And also avoid using DispatchQueue.main.sync on main thread (by default your code is already running on main thread), as it is synchronous and might result in deadlock!
Thanks for the heads up! Will update the snippets.