Paula
Paula

Reputation: 1

How to reload WebImage when url is changed (swift)?

I'm a beginner and sorry for my (probably stupid question)

I use the SDWebImageSwiftUI framework and WebImage to display images from the URL (from firebase). My picture should change on Player if I change the song. I use @State and @Binding to connect a few views and data changes properly (URL, title, etc are actualized). Some time ago everything worked great, and now I don't know when exactly it crashed. On appear player, when the image is displayed the first time work well but stays the same when the song changes.

public struct Song: Identifiable, Codable, Hashable {
   public var id: String = UUID().uuidString
   var image: String
   var title: String
   var author: String
   var track: String
}

WebImage(url: URL(string: song.image)) 

So, what should I do to WebImage changes properly?

Upvotes: 0

Views: 78

Answers (0)

Related Questions