Hi I have a struct like this
struct OrderCaches: Codable {
var food, drink: [Food]?
}
struct Food: Codable{
var id: Int?
var name: String?
var quantity: Double?
var notes: String?
}
I want to get first index where id = productList[indexPath.row].id
I tried with:
let index = OrderCaches.firstIndex(where: {$0.food.id == productList[indexPath.row].id})
but not work I get this error "Value of type '[Food]?' has no member 'id'". How can I get the first Index? Thanks