I'm attempting to write the following code in swift, but having trouble doing so:
Objective - C:
NSArray * seachArray = [sessionSearchResults filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(ProductModel* evaluatedObject, NSDictionary *bindings) {
return [evaluatedObject.productName rangeOfString:searchString options:NSCaseInsensitiveSearch].location != NSNotFound;
}]];
Swift (What I have so far)
func searchDisplayController(controller: UISearchDisplayController, shouldReloadTableForSearchString searchString: String!) -> Bool {
let filteredArray = searchArray.filter { (session: ProductModel) -> Bool in
//Contains String?
return session.productName == searchString
}
var S : String
for S in filteredArray {
println(S)
}
return true
}
Just curious. Is there a away to achieve this without importing foundation?