<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>winter</key>
<dict>
<key>parents</key>
<string>barbados</string>
<key>girlfriend</key>
<string>hawaii</string>
<key>friends</key>
<string>honolulu</string>
</dict>
</dict>
</plist>
enum Calendar: String, CaseIterable, Codable {
case spring
case summer
case fall
case winter
}
enum HolidayHome: String, CaseIterable, Codable {
case barbados
case hawaii
case honolulu
}
struct HolidayPlanner: Codable {
struct Season: Codable {
var spring: [Calendar.AllCases : String]
}
struct Destination: Codable {
var barbados: [HolidayHome.AllCases : String]
}
var spring: Season
var barbados: Destination
private enum CodingKeys : String, CodingKey {
case spring
case barbados
}
}
I wanted to model a plist that I dynamically create to better manage the data, but I can’t figure out how to serialize the data from the plist into struct?
The problem is that each nested level, not being static, prevents me from doing this. I tried hardcoding the first nested level “spring” with an aim to iterate over all of the possible cases in the enum, but it didn’t work, and I don’t know if this is the right approach?