I am trying to implement a search bar where the user can type in a string and search for an address or a business.
To find businesses I use Yelp APIs to outsource the in
What you're seeing here is the MKError.loadingThrottled
error. You will have to delay requests you're sending to Apple.
You can do this by restarting a timer every time the user updates the search query. You can adjust how frequently you ping the API by extending the length of the timer. By resetting the timer each time the query is updated, you avoid sending multiple requests when the characters are changing rapidly.
// declare and store Timer somewhere
func searchAddress(with query: String) {
}
func timerDidFire(_ sender: Any) {
let query = textField.text
searchAddress(with: query)
}
Timer.scheduledTimerWithTimeInterval(0.5, target: self, selector: #selector(timerDidFire), userInfo: nil, repeats: false)