class Model: ObservableObject {
@Published var players: [Player] = []
}
struct PlayerListView: View {
@ObservedObject var model: Model
var body: some View {
List(model.players, id: \.score) { player in
HStack {
Text("Name: \(player.name)")
Text("Score: \(player.score)")
Text("Status: \(player.status)")
Text("Salary: \(player.salary)")
}
}
}
}
struct Player: Codable {
let name: String
let score: Int
let salary: Int
let status: String
}
so the problem is, if I am performing any operation that increase or decrease the count of players array then view is getting refreshed as expected, but when something internal gets changed like Name, score or any thing by some operations like api calls view is not getting refreshed can anyone please help me out
these solutions are not working in ios14 or above self.objectWillChange.send()
nameislet?struct Players: Codable { var name: String // var .... }Note thevarand thestructnotStruct