I am filtering an array that can have a value where there are multiple Models of the same name, only they have different model numbers.
Variables
var modelArray = [model]()
Struct
struct model {
var modelName = String();
var modelNumber = String();
var manufacturer = String();
var phiTypeCode = String();
var phiTypeDesc = String();
}
Filter
var filteredArray = self.modelArray.filter { $0.manufacturer.range(of: manufacturerVar, options: .caseInsensitive) != nil }
This produces the correct filtered Array, only due to the possibility of similar models with different model numbers, I am trying to remove duplicates from filteredArray
.
Fairly new to swift I don't have a great deal of experience making the struct hashable to be able to use the suggested solutions.
Hopefully this is more clear