0

I am trying to use Apple's built in location search API (as opposed to Google's as it is free. Below is my code. My problem is that the completion handler for startWithCompletionHandler: never gets called. No exceptions are getting thrown either. What am I doing wrong here? Any help would be greatly appreciated.

MKLocalSearchRequest *searchRequest = [[MKLocalSearchRequest alloc] init];
searchRequest.naturalLanguageQuery = searchText;
searchRequest.region = self.mapView.region;

MKLocalSearch *search = [[MKLocalSearch alloc] initWithRequest:searchRequest];
[search startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) {
    [searchResults addObjectsFromArray:response.mapItems];
    [self.searchResultsTableView setSearchResults:searchResults];
}];
Kevin Coleman
  • 51
  • 1
  • 1
  • How do you know it doesn't get called? Have you tried putting an NSLog inside the completion handler and logged `response` and `error`? Also NSLog the value of `searchText` _before_ calling startWithCompletionHandler and make sure it isn't null or blank. –  Jan 13 '14 at 02:37
  • Thanks Anna, I do indeed have NSLogs in the block. I also have sat with a break point in the block for minutes on end. The block never gets called. Any ideas? – Kevin Coleman Jan 26 '14 at 23:01
  • Did you log the value of searchText before calling initWithRequest? Where is all this code called from? Put a breakpoint on the initWithRequest line. Does execution actually reach there? –  Jan 26 '14 at 23:29

0 Answers0