Skip to content

Instantly share code, notes, and snippets.

@CollectiveHealth-gists
Created August 8, 2017 18:51
Show Gist options
  • Save CollectiveHealth-gists/6fda2bae2ab97e19cee6cb7c3826e50c to your computer and use it in GitHub Desktop.
Save CollectiveHealth-gists/6fda2bae2ab97e19cee6cb7c3826e50c to your computer and use it in GitHub Desktop.
Get Care MKLocalSearchCompletion
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