Created
August 8, 2017 18:51
-
-
Save CollectiveHealth-gists/6fda2bae2ab97e19cee6cb7c3826e50c to your computer and use it in GitHub Desktop.
Get Care MKLocalSearchCompletion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func filterSearchLocation(completer: MKLocalSearchCompleter) | |
throws -> Observable<[MKLocalSearchCompletion]> { | |
// Filter results by titles that contain "United States" keywors | |
let filteredResults = completer | |
.results | |
.filter { $0.title.contains("United States") } | |
// Throw Location not found error | |
guard filteredResults.isEmpty else { throw "Location not found"} | |
// convert an filtered results into an Observable | |
return Observable.just(filteredResults) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment