So I'm not sure why, but I have a custom object
struct Country {
id: Int,
name: String
}
//List of Countries
dataArray = [Country]()
//Error: "Cannot invoke filter with an arg list of type ((Country)) throws -> Bool
filteredArray = dataArray.filter({ (country) -> Bool in
let countryText:NSString = country.name as NSString
return (countryText.range(of: searchString, options: NSString.CompareOptions.caseInsensitive).location) != NSNotFound
})
If dataArray was a list of Strings instead then it'll work, I just don't understand why, looking at other SO questions I am returning a boolean
Filter array of custom objects in Swift
Swift 2.0 filtering array of custom objects - Cannot invoke 'filter' with an argument of list type