2 Replies
      Latest reply on May 29, 2019 12:16 AM by MissLIBRA
      KyleKai Level 1 Level 1 (10 points)

        I am using MKLocalSearch in two companion apps, one for Mac OSX and one for iPhone.  I noticed that MKLocalSearch stopped working correctly, and it appears to have stopped working under Mojave.  The iPhone app continues to work correctly when using identical code.


        For the Mac, whatever region I give to MKLocalSearchRequest, the results from startWithCompletionHandler are always local to the users current location.  This works fine for iOS.  Anyone else notice this?


        An example is below.  I live in San Diego.  I scroll the map to New York, enter a search string of "gas" and the results are 10 gas stations around San Diego.  This happens regardless of where the map is scrolled or zoomed.  On iOS the results are around New York.  On Mac, the results are around San Diego.



        - (IBAction)didEnterTextAction:(id)sender {
             NSTextField* textField = sender;
             if( textField.stringValue.length > 0 ) {
                  NSLog(@"text: %@", textField.stringValue);
                  MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init];
                  request.naturalLanguageQuery = textField.stringValue;
                  request.region = self.mapView.region;
                  MKLocalSearch* localSearch = [[MKLocalSearch alloc] initWithRequest:request];
                  MKLocalSearchCompletionHandler completionHandler = ^(MKLocalSearchResponse *response, NSError *error)
                       if (error != nil) {
                            NSLog(@"Eror finding places:%@", error.localizedDescription);
                            [self presentError:error];
                       } else {
                            NSArray* mapItems = [response mapItems];
                            if( mapItems.count > 0 ) {
                                 NSLog(@"Found %lu items", (unsigned long)mapItems.count);
                                 [mapItems enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop){
                                      MKMapItem* mapItem = obj;
                                      NSLog(@"mapItem.placemark:%@", mapItem.placemark);
                  [localSearch startWithCompletionHandler:completionHandler];