CLGeocoder Reverse Geocoding Problem

Discussion in 'iOS Programming' started by Fuzzball27, Jan 7, 2012.

  1. Fuzzball27 macrumors member

    Fuzzball27

    Joined:
    Aug 8, 2011
    #1
    When I run this method, NSLog doesn't give any results. What am I missing?
    Code:
    -(void)cityState:(CLLocation *)l
    {
        CLGeocoder *geocoder = [[[CLGeocoder alloc] init] autorelease];
        [geocoder reverseGeocodeLocation:l completionHandler:^(NSArray *placemarks, NSError *error) {
            CLPlacemark *placemark = [placemarks objectAtIndex:0];
            [self setCity:[placemark locality]];
            [self setState:[placemark administrativeArea]];
            NSLog(@"%@ %@", city, state);
        }];
    }
    
     
  2. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    If the NSLog isn't outputting anything, wouldn't that suggest that the method simply isn't being called?

    Set a breakpoint in the method to verify its getting called.
     
  3. North Bronson macrumors 6502

    Joined:
    Oct 31, 2007
    Location:
    San José
    #3
    Why did you choose to autorelease the geocoder?
     
  4. Fuzzball27 thread starter macrumors member

    Fuzzball27

    Joined:
    Aug 8, 2011
    #4
    The method is being called.

    ----------

    Convenience. It was in one of apple's examples.
     
  5. Sydde macrumors 68020

    Sydde

    Joined:
    Aug 17, 2009
    #5
    NSLog is not outputting anything: does that mean you see the log stamp (date, time, etc) with no string following, or is there no log stamp at all?

    And have you tried checking whether there is a reported error?
     
  6. Fuzzball27 thread starter macrumors member

    Fuzzball27

    Joined:
    Aug 8, 2011
    #6
    I just realized the problem. I wasn't connected to the internet. It's working fine now. Thank you for the help.
     

Share This Page