I have an array of strings that a returned from an API. These strings are a list of products available.
I would like to use an enum in my app to represent this data. I am unsure if this is possible however.
enum Products: String {
case music
case cars
case sport
}
An example array I receive could be ["music", "cars"]
This is part of a struct that would be
struct CustomerState: Codable {
var products = [Product]()
}
I was imaging I could map of the array and perhaps compare raw values, however I cannot work out how to do this or if this is the correct / possible approach.
Productsconforms toCodableshould do the trick.