0

I have an CLLocationCoordinate2D object which contains the coordinate of a location.

I want to set the property city (NSString) to the city name of this location.

Note: I'm using Google Maps iOS SDK if it's matters.

Note II: I'm not using -reverseGeocoder: didFindPlacemark: so this question is not relevant for me.

The completion handler block is never called.

GMSGeoCode code:

 //Checking user's city
        __block NSString *userCity;
        [[GMSGeocoder geocoder]reverseGeocodeCoordinate:self.locationManager.location.coordinate completionHandler:^(GMSReverseGeocodeResponse *response, NSError *error) {//skips completionHandler for some reason
            if (error) {
                NSLog(@"%@",[error description]);
            }
            userCity=[[[response results] firstObject] locality];
        }];
        //Checking saved city
        __block NSString *arounderCity;
        [[GMSGeocoder geocoder]reverseGeocodeCoordinate:arounder.radiusCircularRegion.center completionHandler:^(GMSReverseGeocodeResponse *response, NSError *error) {
            if (error) {
                NSLog(@"%@",[error description]);
            }
            arounderCity=[[[response results] firstObject] locality];
        }];
        if ([userCity isEqualToString:arounderCity]) {
            return YES;
        }

Anyone have an idea how to get the city name?

Thanks!

Community
  • 1
  • 1
FS.O
  • 403
  • 6
  • 24
  • Possible duplicate of [How to retrieve user's current city name?](http://stackoverflow.com/questions/1382900/how-to-retrieve-users-current-city-name) – Andrey Chernukha Feb 15 '16 at 18:55
  • @AndreyChernukha Edited the post – FS.O Feb 15 '16 at 19:02
  • Do you have a valid Google Maps key, properly configured? Does your location manager have a valid location? Simplify your test by passing a hard coded Location coordinate instead of querying Core Location. – Hal Mueller Feb 16 '16 at 06:41
  • @HalMueller everything is fine and working, the geoCoder is the only problem – FS.O Feb 16 '16 at 10:01
  • Possible duplicate of [GMSGeoCoder reverseGeocodeCoordinate: completionHandler: on background thread](http://stackoverflow.com/questions/35434026/gmsgeocoder-reversegeocodecoordinate-completionhandler-on-background-thread) – Hal Mueller Feb 16 '16 at 21:29

0 Answers0