Home > Mobile >  My FlightData Master Data Structure does not conform to Decodable when using other Data Structures
My FlightData Master Data Structure does not conform to Decodable when using other Data Structures

Time:08-21

I am trying to build a master structure of data that is built based upon other model structures I have used. Below is my code:

struct AirportFlightData: Codable {
    let scheduled_arrivals = [Scheduled_Arrivals].self
    let scheduled_departures = [Scheduled_Departures].self
    let arrivals = [ArrivalData].self
    let departures = [DepartureData].self
}

All of the above conform to Codable, (Inclusive of Encode/Decodable) however this master structure does not. How can I resolve this?

CodePudding user response:

struct AirportFlightData: Codable {
    let scheduled_arrivals : [Scheduled_Arrivals]
    let scheduled_departures : [Scheduled_Departures]
    let arrivals : [ArrivalData]
    let departures : [DepartureData]
}

You set the type in swift with : not .self.

  • Related