wider-spider
wider-spider

Reputation: 515

MKLocalSearch produces SearchAttribution Error and Error Domain=GEOErrorDomain Code=-8

I search places with the MKLocalSearchCompleter and refine the results when the tableView cell is selected. When a MKLocalSearchCompletion is selected and MKLocalSearch.Request() is started, I get these Errors (example selects Los Angeles): According to my research this is a very rare problem?!

These are the instance variables in a TableViewController:

var searchCompleter = MKLocalSearchCompleter()
var searchResults = [MKLocalSearchCompletion]()

This code is running everytime the search term is changed:

searchCompleter.queryFragment = text
searchCompleter.resultTypes = .address
searchCompleter.region = region

In tableView … didSelectRowAt… this code is executed:

let selectedItem = searchResults[indexPath.row]
        
let searchRequest = MKLocalSearch.Request()
searchRequest.naturalLanguageQuery = selectedItem.title
searchRequest.resultTypes = .address
        
let search = MKLocalSearch(request: searchRequest)
search.start { (response, error) in
            
      guard let coordinate = response?.mapItems[0].placemark.coordinate else {
          return
      }
      // send to mainVC
     self.delegate?.userSelectedPlace(coordinate: coordinate)
}

Xcode 12.4, iOS 14.4 Simulator

Upvotes: 6

Views: 530

Answers (1)

MarkZ
MarkZ

Reputation: 47

I had a similar error when I tried to load search results into table view. Then I found that my table view's datasource and delegate is missing. So make sure your tableview's delegate and datasource outlets point to the right file owner.

enter image description here

Upvotes: -1

Related Questions