I have this enum:
enum Animal {
case cat(CatModel)
case dog(DogModel)
}
And an array of animals:
var animals: [Animal]
I need to find a Cat object in this array by a property that Dog doesn't have. litterBoxId
for example.
let cat = animals.first(where: {$0.litterBoxId == 7})
This of course has an error:
Value of type 'MyViewController.Animal' has no member 'litterBoxId'
How can I accomplish this? I also tried
($0 as CatModel).litterBoxId