I have a plist which is an array of dictionaries. (root is array).
Each dic have 2 values for sure : name, and icon as Strings.
But some of them have more keys/values, some don't.
I am trying to read the array into a structure with :
struct Config: Decodable {
private enum CodingKeys: String, CodingKey {
case name, icon
}
let name: String
let icon: String
}
func functionsStruct() -> Config {
let url = Bundle.main.url(forResource: "FunctionsList", withExtension: "plist")!
let data = try! Data(contentsOf: url)
let decoder = PropertyListDecoder()
return try! decoder.decode(Config.self, from: data)
}
I read a dictionary, how to read an array of dictionaries and how to set up the structure.
how to solve it that some dics have keys that others don't ?