Let's say you have an array of Car structs, which incorporates an array of previous owners.
struct Car {
var model: String // Ford Taurus
var owners: [Owner]
}
struct Owner {
var name: String // Harrison Ford
var location: String // Oxford
}
When people search for "Ford" I want to check the Car model as well as the Owner name and location for the word 'ford'. I know how to filter the Car model, but not the Owner properties.
let filteredCars = cars.filter { (car) -> Bool in
return car.model.lowercased().contains(textToSearch.lowercased())
}
How do I filter the owner properties as well?