Post

Replies

Boosts

Views

Activity

Reply to SwiftUI struct var declaration problem
I have another problem, there it is my structure : struct PlayerStats: Decodable, Identifiable {     var id: String? {         self.name     }     var name: String?     var value: Any?     init(name: String, value: Any) {         self.name = name         self.value = value     }     init(from decoder: Decoder) throws {         if let int = try? decoder.singleValueContainer().decode(Int.self) {             self.value = int             return         }         if let string = try? decoder.singleValueContainer().decode(String.self) {             self.value = string             return         }     } } my code : ForEach(data.stats) { stat in Text(stat.name!)       Text("\(stat.value)") } issue : Instance method 'appendInterpolation(_:formatter:)' requires that 'Any?' inherit from 'NSObject'
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22