SWIFT. How to write a structure for data correctly IN XCODE

37 views Asked by At

I ask for a hint on how to write the structure and data model correctly. I want a piece of data from the decoder. Is it possible to do this?

Important! I was marked with a "???" a place where I don't know what to write.

class TodayViewModel : ObservableObject {
    @Published var today = ""
    @Published var tomorrow = ""
    
    func updateText() {
        HoroscopeDecoder.shared.run(sign: .aries) { prediction in
            DispatchQueue.main.async {
                self.today = prediction[0]
                self.tomorrow = prediction[1]
            }
        }
    }
}

struct Sign: Identifiable {
    
    var id = UUID()
    var title: String
    var image: String
    var today: **???**
    var tomorrow: **???**
}


let signsData: [Sign] = [
    Sign(title: "Овен", image: "aries", today: **???**,  tomorrow: **???**)
]

On the screen, I drew in more detail what I want to get. enter image description here

0

There are 0 answers